summaryrefslogtreecommitdiffstats
path: root/Lib/test/script_helper.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-12-03 01:23:10 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-12-03 01:23:10 (GMT)
commit7e59ce8b07127fade6400ea5d66a12ef4ae68475 (patch)
tree73b26e556f0079520299a1555419e99625469785 /Lib/test/script_helper.py
parentab68fcaee3c39ad21cf3a62f6d299e79a2c1fd56 (diff)
downloadcpython-7e59ce8b07127fade6400ea5d66a12ef4ae68475.zip
cpython-7e59ce8b07127fade6400ea5d66a12ef4ae68475.tar.gz
cpython-7e59ce8b07127fade6400ea5d66a12ef4ae68475.tar.bz2
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.
Diffstat (limited to 'Lib/test/script_helper.py')
-rw-r--r--Lib/test/script_helper.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/test/script_helper.py b/Lib/test/script_helper.py
index 7f7c70e..6be47bd 100644
--- a/Lib/test/script_helper.py
+++ b/Lib/test/script_helper.py
@@ -134,9 +134,9 @@ def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
# zip_file.close()
return zip_name, os.path.join(zip_name, name_in_zip)
-def make_pkg(pkg_dir):
+def make_pkg(pkg_dir, init_source=''):
os.mkdir(pkg_dir)
- make_script(pkg_dir, '__init__', '')
+ make_script(pkg_dir, '__init__', init_source)
def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
source, depth=1, compiled=False):