* ==========================
*/
-/* C equivalent of gc.collect(). */
+/* C equivalent of gc.collect() which ignores the state of gc.enabled. */
PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
#ifndef Py_LIMITED_API
PyAPI_FUNC(Py_ssize_t) _PyGC_CollectNoFail(void);
+PyAPI_FUNC(Py_ssize_t) _PyGC_CollectIfEnabled(void);
#endif
/* Test if a type has a GC head */
* 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_Collect();
+ _PyGC_CollectIfEnabled();
#ifdef COUNT_ALLOCS
/* With COUNT_ALLOCS, it helps to run GC multiple times:
each collection might release some types from the type
list, so they become garbage. */
- while (PyGC_Collect() > 0)
+ while (_PyGC_CollectIfEnabled() > 0)
/* nothing */;
#endif
/* Destroy all modules */
* XXX Python code getting called.
*/
#if 0
- PyGC_Collect();
+ _PyGC_CollectIfEnabled();
#endif
/* Disable tracemalloc after all Python objects have been destroyed,