[issue14583] try/except import fails --without-threads
Brett Cannon
report at bugs.python.org
Sun May 6 21:24:32 CEST 2012
Brett Cannon <brett at python.org> added the comment:
So I was going to try to figure out the logic, so I manually created the test files to start debugging, but I didn't get the ImportError but instead the 1/0 error for the relative import. Maybe it's specific to lack of threads or the change you made? I mean if that's how it has always worked then I'm not arguing that it's wrong, just that it's a weird side-effect:
>>> import pkg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 977, in _find_and_load
File "<frozen importlib._bootstrap>", line 596, in load_module
File "<frozen importlib._bootstrap>", line 262, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 484, in _load_module
File "./pkg/__init__.py", line 3, in <module>
1/0
ZeroDivisionError: division by zero
[70552 refs]
>>> import sys
[70554 refs]
>>> sys.modules['pkg']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'pkg'
[70462 refs]
>>> sys.modules['pkg.module']
<module 'pkg.module' from './pkg/module.py'>
[70465 refs]
>>> with open('pkg/__init__.py') as file: print(file.read())
...
from . import module
#import pkg.module
1/0
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14583>
_______________________________________
More information about the Python-bugs-list
mailing list