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 serhiy.storchaka
Recipients eric.snow, pitrou, serhiy.storchaka, vstinner
Date 2020-12-18.07:36:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608277003.15.0.927138590111.issue42671@roundup.psfhosted.org>
In-reply-to
Content
I experimented with different approaches last evening. Just changing the order of clearing the module dict does not help your first example, because the __main__ module is garbage collected, but its dict is not cleared. Adding _PyModule_ClearDict() in tp_dealloc and tp_clear helps with that example, but it causes several failures and crashes in tests. I have found issue7140 and issue18214 for not clearing module dicts.

So in conclusion, your approach may work. It clears dicts of all modules, but only at shutdown. It did not worked before, when the order of dicts was undetermined, but now we can utilize deterministic order of sys.modules and module dicts.
History
Date User Action Args
2020-12-18 07:36:43serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, vstinner, eric.snow
2020-12-18 07:36:43serhiy.storchakasetmessageid: <1608277003.15.0.927138590111.issue42671@roundup.psfhosted.org>
2020-12-18 07:36:43serhiy.storchakalinkissue42671 messages
2020-12-18 07:36:42serhiy.storchakacreate