mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
bpo-38920: Add audit hooks for when sys.excepthook and sys.unraisable hooks are invoked (GH-17392)
Also fixes some potential segfaults in unraisable hook handling.
This commit is contained in:
parent
02519f75d1
commit
bea33f5e1d
7 changed files with 156 additions and 50 deletions
|
@ -695,6 +695,14 @@ _PyErr_PrintEx(PyThreadState *tstate, int set_sys_last_vars)
|
|||
}
|
||||
}
|
||||
hook = _PySys_GetObjectId(&PyId_excepthook);
|
||||
if (PySys_Audit("sys.excepthook", "OOOO", hook ? hook : Py_None,
|
||||
exception, v, tb) < 0) {
|
||||
if (PyErr_ExceptionMatches(PyExc_RuntimeError)) {
|
||||
PyErr_Clear();
|
||||
goto done;
|
||||
}
|
||||
_PyErr_WriteUnraisableMsg("in audit hook", NULL);
|
||||
}
|
||||
if (hook) {
|
||||
PyObject* stack[3];
|
||||
PyObject *result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue