[issue12554] Failed imports clean up module, but not sub modules

R. David Murray report at bugs.python.org
Thu Jul 14 01:13:53 CEST 2011


R. David Murray <rdmurray at bitdance.com> added the comment:

Yes, that's exactly my point.  The loading of a module into sys.modules is a separate issue from the creation of a pointer to that module in the local name space.  Once the former succeeds, it has succeeded and won't be done again.  When the module that did the import fails to complete, *it* is cleaned up, which cleans up the pointer in the local name space, but that doesn't (by design) affect sys.modules.

It's not all that dissimilar to what would happen if you had top-level code in your module that opened and wrote to a file.  If an exception later in the module code causes it to fail to load, the file it created would not be deleted.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12554>
_______________________________________


More information about the Python-bugs-list mailing list