]> granicus.if.org Git - python/commitdiff
Bug #1481530: allow "from os.path import ..." with imputil
authorGeorg Brandl <georg@python.org>
Thu, 4 May 2006 05:08:10 +0000 (05:08 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 4 May 2006 05:08:10 +0000 (05:08 +0000)
Lib/imputil.py

index e6ad7ecac4ea0ce2e779d3a68f1326947bc8227b..8a49bb14ff6513ef035fbded954444a04da06c8f 100644 (file)
@@ -131,9 +131,12 @@ class ImportManager:
         if importer:
             return importer._finish_import(top_module, parts[1:], fromlist)
 
-        # Grrr, some people "import os.path"
+        # Grrr, some people "import os.path" or do "from os.path import ..."
         if len(parts) == 2 and hasattr(top_module, parts[1]):
-            return top_module
+            if fromlist:
+                return getattr(top_module, parts[1])
+            else:
+                return top_module
 
         # If the importer does not exist, then we have to bail. A missing
         # importer means that something else imported the module, and we have