diff options
author | Victor Stinner <vstinner@python.org> | 2022-01-22 23:06:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-22 23:06:56 (GMT) |
commit | 12f4ac3bc848244242d6b8a7ee158b985fd64744 (patch) | |
tree | 97646cd4908ef2ac6fd9f3b51d06a180603d3118 /Python/pylifecycle.c | |
parent | 1ded8ed8e817b8f9dae1a0ef92d97983afbc844e (diff) | |
download | cpython-12f4ac3bc848244242d6b8a7ee158b985fd64744.zip cpython-12f4ac3bc848244242d6b8a7ee158b985fd64744.tar.gz cpython-12f4ac3bc848244242d6b8a7ee158b985fd64744.tar.bz2 |
bpo-46417: Clear symtable identifiers at exit (GH-30809)
Add _PySymtable_Fini() function, called by finalize_interp_clear().
Update test_cmd_line.test_showrefcount() to tolerate negative
reference count.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 92c8ad0..9d10f94 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -23,6 +23,7 @@ #include "pycore_runtime_init.h" // _PyRuntimeState_INIT #include "pycore_sliceobject.h" // _PySlice_Fini() #include "pycore_structseq.h" // _PyStructSequence_InitState() +#include "pycore_symtable.h" // _PySymtable_Fini() #include "pycore_sysmodule.h" // _PySys_ClearAuditHooks() #include "pycore_traceback.h" // _Py_DumpTracebackThreads() #include "pycore_tuple.h" // _PyTuple_InitTypes() @@ -1700,6 +1701,9 @@ finalize_interp_clear(PyThreadState *tstate) int is_main_interp = _Py_IsMainInterpreter(tstate->interp); _PyExc_ClearExceptionGroupType(tstate->interp); + if (is_main_interp) { + _PySymtable_Fini(); + } /* Clear interpreter state and all thread states */ _PyInterpreterState_Clear(tstate); |