New submission from ProgVal:

In Python 3.3 (I did not test with 3.4), sys.modules cannot be reassigned 
without breaking the import mechanism; while it works with Python <= 3.2.

Here is how to reproduce the bug:

progval@Andromede:/tmp$ mkdir test_imports
progval@Andromede:/tmp$ echo "from . import module" > test_imports/__init__.py
progval@Andromede:/tmp$ echo "print('foo')" > test_imports/module.py
progval@Andromede:/tmp$ python3.3
Python 3.3.1 (default, Apr  6 2013, 13:58:40) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.modules = dict(sys.modules)
>>> import test_imports
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./test_imports/__init__.py", line 1, in <module>
    from . import module
SystemError: Parent module 'test_imports' not loaded, cannot perform relative 
import
>>> 
progval@Andromede:/tmp$ python3.2
Python 3.2.3 (default, May  6 2013, 01:46:35) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.modules = dict(sys.modules)
>>> import test_imports
foo
>>>

----------
components: Interpreter Core
messages: 188901
nosy: Valentin.Lorentz
priority: normal
severity: normal
status: open
title: sys.modules cannot be reassigned
type: behavior
versions: Python 3.3

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

Reply via email to