[New-bugs-announce] [issue15316] runpy swallows ImportError information with relative imports
Chris Jerdonek
report at bugs.python.org
Tue Jul 10 07:39:18 CEST 2012
New submission from Chris Jerdonek <chris.jerdonek at gmail.com>:
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 <report at bugs.python.org>
<http://bugs.python.org/issue15316>
_______________________________________
More information about the New-bugs-announce
mailing list