diff Lib/importlib/_bootstrap.py @ 55774:99dc22ef1df0

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.
author Brett Cannon <bcannon@gmail.com>
date Sun, 30 Aug 2009 20:22:21 +0000
parents 560008d098dd
children 27e120f9208b
line wrap: on
line diff
--- a/Lib/importlib/_bootstrap.py	Sun Aug 30 20:08:15 2009 +0000
+++ b/Lib/importlib/_bootstrap.py	Sun Aug 30 20:22:21 2009 +0000
@@ -879,7 +879,11 @@
                 _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)