Eric Snow added the comment:

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.

----------
versions: +Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28202>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to