mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #19771: Omit irrelevant message if package could not be initialized
This commit is contained in:
parent
f0c0318cdc
commit
dda584340e
3 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue