Martin Panter added the comment:
Even with my committed fix, tracebacks triggered by initializing a parent
package are still suppressed:
$ ./python -m hello
Traceback (most recent call last):
File "/media/disk/home/proj/python/cpython/Lib/runpy.py", line 158, in
_run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/media/disk/home/proj/python/cpython/Lib/runpy.py", line 116, in
_get_module_details
__import__(mod_name) # Do not catch exceptions initializing package
File "/media/disk/home/proj/python/cpython/hello/__init__.py", line 1, in
<module>
import random; random.dsgjdgj
AttributeError: module 'random' has no attribute 'dsgjdgj'
[Exit 1]
$ ./python -m hello.submodule
/media/disk/home/proj/python/cpython/python: Error while finding spec for
'hello.submodule' (<class 'AttributeError'>: module 'random' has no attribute
'dsgjdgj')
[Exit 1]
Fixing this in general might require a loop around the find_spec() call as in
init-ancestor.patch. But I’m unsure if it is worth the extra complication.
----------
Added file: http://bugs.python.org/file41231/init-ancestor.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue14285>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com