summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2019-11-28 08:46:11 -0800
committerGitHub <noreply@github.com>2019-11-28 08:46:11 -0800
commitbea33f5e1db6e4a554919a82894f44568576e979 (patch)
tree37789378933d7091eb0012d6ad3277aa8685a979 /Python/pythonrun.c
parent02519f75d15b063914a11351da30178ca4ceb54b (diff)
downloadcpython-git-bea33f5e1db6e4a554919a82894f44568576e979.tar.gz
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.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 77a95ceb94..b68a0b5572 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;