diff options
author | Martin Panter <vadmium+py@gmail.com> | 2015-12-12 06:58:55 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2015-12-12 06:58:55 (GMT) |
commit | dda584340e88004b534de6c24a39633bdfdf0104 (patch) | |
tree | 465d781d47d5430fde385ea9d9e5fb2ff97cb2af /Lib/runpy.py | |
parent | f0c0318cdc72cbc65014f3a550efb4c8a737b9e3 (diff) | |
download | cpython-dda584340e88004b534de6c24a39633bdfdf0104.zip cpython-dda584340e88004b534de6c24a39633bdfdf0104.tar.gz cpython-dda584340e88004b534de6c24a39633bdfdf0104.tar.bz2 |
Issue #19771: Omit irrelevant message if package could not be initialized
Diffstat (limited to 'Lib/runpy.py')
-rw-r--r-- | Lib/runpy.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py index c98af19..af6205d 100644 --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -132,6 +132,8 @@ def _get_module_details(mod_name, error=ImportError): pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name, error) except error as e: + if mod_name not in sys.modules: + raise # No module loaded; being a package is irrelevant raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name)) loader = spec.loader |