mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
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().
This commit is contained in:
parent
4fe72090de
commit
eba5bf2f56
4 changed files with 35 additions and 15 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue