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

Co-authored-by: Konge <zkonge@outlook.com>
This commit is contained in:
Steve Dower 2020-07-03 22:58:29 +01:00 committed by GitHub
parent 1c776541a8
commit e1d4fdc533
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 45 deletions

View file

@ -1303,6 +1303,13 @@ finalize_interp_clear(PyThreadState *tstate)
finalize_interp_types(tstate, is_main_interp);
/* 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);
}
if (is_main_interp) {
/* XXX Still allocated:
- various static ad-hoc pointers to interned strings
@ -1419,9 +1426,6 @@ Py_FinalizeEx(void)
*/
_PyGC_CollectIfEnabled();
/* Clear all loghooks */
_PySys_ClearAuditHooks(tstate);
/* Destroy all modules */
_PyImport_Cleanup(tstate);