summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2020-07-03 21:58:29 (GMT)
committerGitHub <noreply@github.com>2020-07-03 21:58:29 (GMT)
commite1d4fdc53347617bea1aff0d7112471453f65003 (patch)
tree16f76a529a56aaf34b47a070341641ea0ac16715 /Python
parent1c776541a8805576c0a4363ca28c1d29423f02f6 (diff)
downloadcpython-e1d4fdc53347617bea1aff0d7112471453f65003.zip
cpython-e1d4fdc53347617bea1aff0d7112471453f65003.tar.gz
cpython-e1d4fdc53347617bea1aff0d7112471453f65003.tar.bz2
bpo-41162: Clear audit hooks later during finalization (GH-21222)
Co-authored-by: Konge <zkonge@outlook.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/pylifecycle.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index eb065eb..e218808 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -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);