[Python-Dev] test___all__ polluting sys.modules?

Richard Oudkerk shibturn at gmail.com
Mon Dec 31 18:35:32 CET 2012

On 30/12/2012 9:52pm, Antoine Pitrou wrote:
> If you have an object with a __del__ method as a module global, the
> cyclic gc will refuse to consider the module globals at all (which
> means it will affect unrelated objects).
> So, yes, I think the shutdown purge is still necessary. Perhaps there
> are ways to make it smarter.

With my earlier suggestion a module deleted from sys.modules before 
shutdown can have an unreclaimable global dict (if it contains a global 
with a __del__ method).

Perhaps, instead, modules could use a weakrefable subclass of dict for 
their globals dicts.  The module destructor could save the global dicts 
of deleted modules in a registry.  At shutdown any remaining globals 
dicts can be purged.


More information about the Python-Dev mailing list