bpo-41162: Clear audit hooks later during finalization (GH-21222)

This commit is contained in:
Konge 2020-07-04 05:06:46 +08:00 committed by GitHub
parent d160e0f8e2
commit daa0fe03a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 45 deletions

View file

@ -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);