Author chris.jerdonek
Recipients chris.jerdonek
Date 2012-07-10.05:39:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341898758.4.0.623810416258.issue15316@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-07-10 05:39:18chris.jerdoneksetrecipients: + chris.jerdonek
2012-07-10 05:39:18chris.jerdoneksetmessageid: <1341898758.4.0.623810416258.issue15316@psf.upfronthosting.co.za>
2012-07-10 05:39:17chris.jerdoneklinkissue15316 messages
2012-07-10 05:39:17chris.jerdonekcreate