summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-10-30 21:51:02 (GMT)
committerGitHub <noreply@github.com>2020-10-30 21:51:02 (GMT)
commiteba5bf2f5672bf4861c626937597b85ac0c242b9 (patch)
tree914219482fdbb19af1c54f1b6c9b81a67611c990 /Python/pylifecycle.c
parent4fe72090deb7fb7bc09bfa56c92f6b3b0967d395 (diff)
downloadcpython-eba5bf2f5672bf4861c626937597b85ac0c242b9.zip
cpython-eba5bf2f5672bf4861c626937597b85ac0c242b9.tar.gz
cpython-eba5bf2f5672bf4861c626937597b85ac0c242b9.tar.bz2
bpo-42208: Call GC collect earlier in PyInterpreterState_Clear() (GH-23044)
The last GC collection is now done before clearing builtins and sys dictionaries. Add also assertions to ensure that gc.collect() is no longer called after _PyGC_Fini(). Pass also the tstate to PyInterpreterState_Clear() to pass the correct tstate to _PyGC_CollectNoFail() and _PyGC_Fini().
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index adef161..ff58c1b 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1576,10 +1576,7 @@ finalize_interp_clear(PyThreadState *tstate)
int is_main_interp = _Py_IsMainInterpreter(tstate);
/* Clear interpreter state and all thread states */
- PyInterpreterState_Clear(tstate->interp);
-
- /* Last explicit GC collection */
- _PyGC_CollectNoFail(tstate);
+ _PyInterpreterState_Clear(tstate);
/* Clear all loghooks */
/* Both _PySys_Audit function and users still need PyObject, such as tuple.
@@ -1588,8 +1585,6 @@ finalize_interp_clear(PyThreadState *tstate)
_PySys_ClearAuditHooks(tstate);
}
- _PyGC_Fini(tstate);
-
if (is_main_interp) {
_Py_HashRandomization_Fini();
_PyArg_Fini();