New submission from Chris Jerdonek <[email protected]>:
With the following package directory structure--
foo/
__init__.py
__main__.py
from foo import bar
bar.py
print('***')
raise ImportError('test...')
Running--
$ ./python.exe -m foo
Yields--
***
Traceback (most recent call last):
File ".../python/cpython/cpython/Lib/runpy.py", line 162, in
_run_module_as_main
"__main__", fname, loader, pkg_name)
File ".../python/cpython/cpython/Lib/runpy.py", line 75, in _run_code
exec(code, run_globals)
File "./foo/__main__.py", line 1, in <module>
from foo import bar
ImportError: cannot import name bar
$
The exception text gets swallowed.
Changing the relative import "from foo import bar" to "import foo.bar" does
show the exception text.
----------
components: Library (Lib)
messages: 165166
nosy: cjerdonek
priority: normal
severity: normal
status: open
title: runpy swallows ImportError information with relative imports
versions: Python 3.3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15316>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com