diff options
author | Konge <zkonge@outlook.com> | 2020-07-04 05:06:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-03 22:06:46 +0100 |
commit | daa0fe03a517d335d48e65ace8e5da636e265a8f (patch) | |
tree | d6504f9bc7ae8a6c8d14c0da18e6e46c138231fb /Python | |
parent | d160e0f8e283d0a8737644588b38e8c6a07c134f (diff) | |
download | cpython-git-daa0fe03a517d335d48e65ace8e5da636e265a8f.tar.gz |
bpo-41162: Clear audit hooks later during finalization (GH-21222)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pylifecycle.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 3ce2c41ef1..2d219a4a3a 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1291,6 +1291,13 @@ finalize_interp_clear(PyThreadState *tstate) _PyGC_CollectNoFail(); } + /* Clear all loghooks */ + /* Both _PySys_Audit function and users still need PyObject, such as tuple. + Call _PySys_ClearAuditHooks when PyObject available. */ + if (is_main_interp) { + _PySys_ClearAuditHooks(tstate); + } + _PyGC_Fini(tstate); if (is_main_interp) { @@ -1405,9 +1412,6 @@ Py_FinalizeEx(void) */ _PyGC_CollectIfEnabled(); - /* Clear all loghooks */ - _PySys_ClearAuditHooks(tstate); - /* Destroy all modules */ _PyImport_Cleanup(tstate); |