diff options
author | Steve Dower <steve.dower@python.org> | 2019-11-28 16:46:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-28 16:46:23 (GMT) |
commit | b74a6f14b94d36fb72b1344663e81776bf450847 (patch) | |
tree | c02fcc9ccb6ec32da2b9f7adcf776285c405f16e /Python/pythonrun.c | |
parent | 18d8edbbb6626ac9cdf1152a720811beb2230b33 (diff) | |
download | cpython-b74a6f14b94d36fb72b1344663e81776bf450847.zip cpython-b74a6f14b94d36fb72b1344663e81776bf450847.tar.gz cpython-b74a6f14b94d36fb72b1344663e81776bf450847.tar.bz2 |
bpo-38920: Add audit hooks for when sys.excepthook and sys.unraisablehook are invoked (GH-17392)
Also fixes some potential segfaults in unraisable hook handling.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index c9afa8f..a7da143 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -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; |