]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Issue #14285: Do not catch ImportError from __init__.py in runpy
authorMartin Panter <vadmium+py@gmail.com>
Thu, 3 Dec 2015 01:23:10 +0000 (01:23 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Thu, 3 Dec 2015 01:23:10 +0000 (01:23 +0000)
commit7e59ce8b07127fade6400ea5d66a12ef4ae68475
tree73b26e556f0079520299a1555419e99625469785
parentab68fcaee3c39ad21cf3a62f6d299e79a2c1fd56
Issue #14285: Do not catch ImportError from __init__.py in runpy

Initialize package before calling get_loader() for __main__, so that we do
not incorrectly handle ImportError from __init__.py. When runpy is used from
the Python CLI, use an internal exception rather than ImportError, to avoid
catching an unexpected ImportError.

Also simplify message formatting: str() is redundant with %s.

Also fix test_dash_m_error_code_is_one() in test_cmd_line_script, which was
failing because the test package was not in the current directlry, rather
the desired ValueError.
Lib/runpy.py
Lib/test/script_helper.py
Lib/test/test_cmd_line_script.py
Lib/test/test_runpy.py
Misc/NEWS