diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 8 | ||||
-rw-r--r-- | Python/pythonrun.c | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Python/import.c b/Python/import.c index b77eda106d..cd4fb788a1 100644 --- a/Python/import.c +++ b/Python/import.c @@ -403,6 +403,14 @@ PyImport_Cleanup(void) } } + /* Collect garbage remaining after deleting the modules. Mostly + reference cycles created by classes. */ + PyGC_Collect(); + + /* Dump GC stats before it's too late, since it uses the warnings + machinery. */ + _PyGC_DumpShutdownStats(); + /* Next, delete sys and builtins (in that order) */ value = PyDict_GetItemString(modules, "sys"); if (value != NULL && PyModule_Check(value)) { diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 96b0988ec7..02a4329950 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -544,10 +544,6 @@ Py_Finalize(void) while (PyGC_Collect() > 0) /* nothing */; #endif - /* We run this while most interpreter state is still alive, so that - debug information can be printed out */ - _PyGC_Fini(); - /* Destroy all modules */ PyImport_Cleanup(); @@ -628,6 +624,7 @@ Py_Finalize(void) PyFloat_Fini(); PyDict_Fini(); PySlice_Fini(); + _PyGC_Fini(); /* Cleanup Unicode implementation */ _PyUnicode_Fini(); |