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 eric.snow
Recipients Jack Liu, brett.cannon, eric.snow, ncoghlan
Date 2016-09-19.15:07:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1474297671.36.0.290898393732.issue28202@psf.upfronthosting.co.za>
In-reply-to
Content
To make sure I'm understanding:

* you are using PyDict_DelItemString() on sys.modules
* a module-level variable in the module is not getting cleaned up when the module is deleted from sys.modules
* this worked in Python 3.3 but not in 3.5

It may help to have a more complete test case, perhaps uploaded to this issue with the multiple files zipped up.

Also, does 3.2 have the same behavior as 3.3 or 3.5?  What about 3.6 (currently in beta)?

Note that deleting the module from sys.modules only reduces the refcount by one.  Other objects may still hold a reference to the module or any of its variables.  So nothing in the module would be cleaned up until the refcount hits zero.  For example, if the module was imported in another module and that second module still has a variable bound to the imported module (or the not-destroyed variable) then you would not see your printed message.

The fact that the behavior is different between 3.3 and 3.5 is concerning though.  I'd expect 3.3 to behave like 3.5 is.  It could be that a change in Lib/importlib (or Python/import.c) since 3.3 is leaking module references, though it's unlikely.
History
Date User Action Args
2016-09-19 15:07:51eric.snowsetrecipients: + eric.snow, brett.cannon, ncoghlan, Jack Liu
2016-09-19 15:07:51eric.snowsetmessageid: <1474297671.36.0.290898393732.issue28202@psf.upfronthosting.co.za>
2016-09-19 15:07:51eric.snowlinkissue28202 messages
2016-09-19 15:07:50eric.snowcreate