This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Valentin.Lorentz
Recipients Valentin.Lorentz
Date 2013-05-11.08:23:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1368260613.85.0.746522318662.issue17953@psf.upfronthosting.co.za>
In-reply-to
Content
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
>>>
History
Date User Action Args
2013-05-11 08:23:33Valentin.Lorentzsetrecipients: + Valentin.Lorentz
2013-05-11 08:23:33Valentin.Lorentzsetmessageid: <1368260613.85.0.746522318662.issue17953@psf.upfronthosting.co.za>
2013-05-11 08:23:33Valentin.Lorentzlinkissue17953 messages
2013-05-11 08:23:33Valentin.Lorentzcreate