[issue15623] Init time relative imports no longer work from __init__.so modules
Brett Cannon
report at bugs.python.org
Mon Aug 13 19:18:42 CEST 2012
Brett Cannon added the comment:
So imp.load_dynamic() does add a module to sys.modules (I'm using Python 3.2 here because that's what I have access to, but I verified this yesterday at home)::
Python 3.2.3 (default, May 3 2012, 15:51:42)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import imp
>>> import sys
>>> 'resource' in sys.modules
False
>>> mod = imp.load_dynamic('resource', '/usr/lib/python3.2/lib-dynload/resource.cpython-32mu.so')
>>> mod
<module 'resource' from '/usr/lib/python3.2/lib-dynload/resource.cpython-32mu.so'>
>>> 'resource' in sys.modules
True
IOW it is not needed for ExtensionFileLoader to add the module explicitly to sys.modules.
As for Meador's notice that __init__.py was being imported, I believe Stefan is saying it should work without that file. So deleting __init__.py and only having __init__.so in Python 3.2 should work. If not then this has been a false alarm.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15623>
_______________________________________
More information about the Python-bugs-list
mailing list