mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
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.
This commit is contained in:
parent
18d8edbbb6
commit
b74a6f14b9
7 changed files with 157 additions and 51 deletions
|
|
@ -293,8 +293,8 @@ PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
|
|||
/* Cannot invoke hooks until we are initialized */
|
||||
if (Py_IsInitialized()) {
|
||||
if (PySys_Audit("sys.addaudithook", NULL) < 0) {
|
||||
if (PyErr_ExceptionMatches(PyExc_Exception)) {
|
||||
/* We do not report errors derived from Exception */
|
||||
if (PyErr_ExceptionMatches(PyExc_RuntimeError)) {
|
||||
/* We do not report errors derived from RuntimeError */
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue