mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +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
|
@ -323,8 +323,8 @@ PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
|
|||
/* Cannot invoke hooks until we are initialized */
|
||||
if (runtime->initialized) {
|
||||
if (PySys_Audit("sys.addaudithook", NULL) < 0) {
|
||||
if (_PyErr_ExceptionMatches(tstate, PyExc_Exception)) {
|
||||
/* We do not report errors derived from Exception */
|
||||
if (_PyErr_ExceptionMatches(tstate, PyExc_RuntimeError)) {
|
||||
/* We do not report errors derived from RuntimeError */
|
||||
_PyErr_Clear(tstate);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue