summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-08-30 20:22:21 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-08-30 20:22:21 (GMT)
commit1c1dcbfd5db9ec3e47ca9ddf28e7c6b87f09eb19 (patch)
treef5c9b6ba568ea86b2c0d29c79021ca050b2e7bfd /Lib/importlib/_bootstrap.py
parent82a23fe3925245086460eb7da95bbdc39cd2454a (diff)
downloadcpython-1c1dcbfd5db9ec3e47ca9ddf28e7c6b87f09eb19.zip
cpython-1c1dcbfd5db9ec3e47ca9ddf28e7c6b87f09eb19.tar.gz
cpython-1c1dcbfd5db9ec3e47ca9ddf28e7c6b87f09eb19.tar.bz2
Trying to import a submodule from another module and not a package was raising
AttributeError in importlib when it should be an ImportError. Found when running importlib against test_runpy.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index bd62c36..466b287 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -879,7 +879,11 @@ def _gcd_import(name, package=None, level=0):
_gcd_import(parent)
# Backwards-compatibility; be nicer to skip the dict lookup.
parent_module = sys.modules[parent]
- path = parent_module.__path__
+ try:
+ path = parent_module.__path__
+ except AttributeError:
+ raise ImportError("no module named {}; "
+ "{} is not a package".format(name, parent))
meta_path = sys.meta_path + _IMPLICIT_META_PATH
for finder in meta_path:
loader = finder.find_module(name, path)