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

Benjamin Peterson report at bugs.python.org
Wed Apr 18 05:58:37 CEST 2012


New submission from Benjamin Peterson <benjamin at python.org>:

$ cat > x.py
import sys
sys.modules["x"] = 42

benjamin at localhost ~/dev/python/py3k $ python3
Python 3.2.2 (default, Feb 18 2012, 09:16:28) 
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import x
>>> x
42

$ ./python 
Python 3.3.0a2+ (default:6762b943ee59, Apr 17 2012, 23:57:13) 
[GCC 4.5.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import x
>>> x
<module 'x' from './x.py'>

It's not clear to me whether it's the loader's responsibilty to handle this or __import__.

----------
assignee: brett.cannon
components: Interpreter Core
messages: 158587
nosy: benjamin.peterson, brett.cannon
priority: high
severity: normal
status: open
title: can't modify sys.modules during import with importlib
versions: Python 3.3

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


More information about the Python-bugs-list mailing list