bpo-42208: Pass tstate to _PyGC_CollectNoFail() (GH-23038)

Move private _PyGC_CollectNoFail() to the internal C API.

Remove the private _PyGC_CollectIfEnabled() which was just an alias
to the public PyGC_Collect() function since Python 3.8.

Rename functions:

* collect() => gc_collect_main()
* collect_with_callback() => gc_collect_with_callback()
* collect_generations() => gc_collect_generations()
This commit is contained in:
Victor Stinner 2020-10-30 17:00:00 +01:00 committed by GitHub
parent 99608c733c
commit 8b3414818f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 34 deletions

View file

@ -1293,7 +1293,7 @@ finalize_interp_clear(PyThreadState *tstate)
PyInterpreterState_Clear(tstate->interp);
/* Last explicit GC collection */
_PyGC_CollectNoFail();
_PyGC_CollectNoFail(tstate);
/* Clear all loghooks */
/* Both _PySys_Audit function and users still need PyObject, such as tuple.
@ -1414,7 +1414,7 @@ Py_FinalizeEx(void)
* XXX but I'm unclear on exactly how that one happens. In any case,
* XXX I haven't seen a real-life report of either of these.
*/
_PyGC_CollectIfEnabled();
PyGC_Collect();
/* Destroy all modules */
_PyImport_Cleanup(tstate);