Eric Snow added the comment:

At least for CPython sys.modules is initially set to the modules dict on the 
interpreter struct.  As of 3.4 the import system itself only cares about 
sys.modules (I'll have to double check on builtin___import__).  However, if I 
recall correctly at least part of the import C-API interacts directly with the 
original interpreter copy of the modules dict.

The catch is that setting sys.modules to something else does not also change 
the dict on the interpreter struct.  So they will be out of sync.  This may 
cause problems.  In practice I don't think it's a big deal, but there is no 
guarantee that patching out sys.modules will give you the behavior that you 
expect.

See also issue #12633.

----------

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

Reply via email to