summaryrefslogtreecommitdiff
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c10
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);