Message168111
| Author |
meador.inge |
| Recipients |
Arfrever, brett.cannon, eric.snow, georg.brandl, meador.inge, scoder |
| Date |
2012年08月13日.14:30:03 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1344868204.57.0.737328292822.issue15623@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|