[issue14285] Traceback wrong on ImportError while executing a package

Martin Panter report at bugs.python.org
Wed Mar 11 09:30:58 CET 2015


Martin Panter added the comment:

The patches at Issue 19771 should remove the part of the message that incorrectly says “. . . is a package and cannot be directly executed”. However that still leaves the problem of the suppressed traceback.

I am posting runpy-traceback.patch here which adds some tests to check if the traceback is suppressed. The offending test is marked @expectedFailure. It also points out where the exception is being incorrectly caught, but I haven’t thought of a nice way to fix the problem.

Other changes in the runpy-traceback.patch:

* Removed the exception message rewriting in _run_module_as_main(), because it seems to be redundant with the _get_main_module_details() function
* Fixed test_cmd_line_script.CmdLineTest.test_dash_m_error_code_is_one(), which was only checking the Python exit status, and not verifying that the specific failure was the one anticipated

----------
keywords: +patch
Added file: http://bugs.python.org/file38438/runpy-traceback.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14285>
_______________________________________


More information about the Python-bugs-list mailing list