summaryrefslogtreecommitdiff
path: root/Python/import.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c8
1 files changed, 8 insertions, 0 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)) {