This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients amaury.forgeotdarc, belopolsky, georg.brandl, georg.brandl, jimjjewett
Date 2008-11-11.05:23:54
SpamBayes Score 2.0052506e-05
Marked as misclassified No
Message-id <1226381035.64.0.602376638991.issue1545463@psf.upfronthosting.co.za>
In-reply-to
Content
amaury> What if PyGC_Collect() is called just before?

That would work.  With the following patch:

===================================================================
--- Python/import.c	(revision 67183)
+++ Python/import.c	(working copy)
@@ -498,7 +498,10 @@
 			PyDict_SetItem(modules, key, Py_None);
 		}
 	}
-
+	/* Collect garbage remaining after deleting the
+	   modules. Mostly reference cycles created by new style
+	   classes. */
+ 	PyGC_Collect();
 	/* Next, delete sys and __builtin__ (in that order) */
 	value = PyDict_GetItemString(modules, "sys");
 	if (value != NULL && PyModule_Check(value)) {

$ ./python.exe x.py
creating X('new')
creating X('old')
deleting X('old')
deleting X('new')
History
Date User Action Args
2008-11-11 05:23:56belopolskysetrecipients: + belopolsky, georg.brandl, jimjjewett, amaury.forgeotdarc, gbrandl.historic
2008-11-11 05:23:55belopolskysetmessageid: <1226381035.64.0.602376638991.issue1545463@psf.upfronthosting.co.za>
2008-11-11 05:23:54belopolskylinkissue1545463 messages
2008-11-11 05:23:54belopolskycreate