[issue14609] can't modify sys.modules during import with importlib

Eric Snow report at bugs.python.org
Wed Apr 18 07:30:06 CEST 2012


Eric Snow <ericsnowcurrently at gmail.com> added the comment:

_find_and_load() in importlib._bootstrap returns whatever the loader returns, which is the new module object.  The old code in import.c pulled it from sys.modules rather than using what the loader returned.  In both cases the respective object is what eventually gets bound to the name in the eval loop.

FWIW, the language reference says, "The first form of import statement binds the module name in the local namespace to the module object".    This looks like a corner case where backwards-compatibility breaks (when we finally start enforcing the rules).

----------

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


More information about the Python-bugs-list mailing list