[issue15623] Init time relative imports no longer work from __init__.so modules

Meador Inge report at bugs.python.org
Mon Aug 13 16:30:04 CEST 2012


Meador Inge added the comment:

I debugged this a bit by comparing the behavior of 3.3 against 3.2.  For both cases I used the following code and debugged it in Python via pdb*:

   import importlib
   importlib.__import__('my_test_package')

ISTM that the difference in behavior is a result of what loader gets chosen for the initial `import 'my_test_package'`.

With 3.2 a importlib._bootstrap._SourceFileLoader loader gets created against 'my_test_package/__init__.py'.  This works fine because _SourceFileLoader fixes up sys.modules when it loads.

With 3.3 a _frozen_importlib.ExtensionFileLoader loader gets created against 'my_test_package/__init__.so'.  This doesn't work because ExtensionFileLoader does *not* fixup sys.module when it loads.

I hope that helps some.


* Which was a real pain for 3.3 since you are debugging the frozen importlib.  You get line numbers at least, but it would be really nice if you could tell pdb a source file to use when you are dealing with bytecode only objects and\or you could disassemble the bytecode from pdb.

----------

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


More information about the Python-bugs-list mailing list