diff Lib/importlib/_bootstrap.py @ 52080:65371df41aca

Fix importlib._bootstrap.PyPycLoader.load_module() to better handle source/bytecode paths and what to do when they don't exist.
author Brett Cannon <bcannon@gmail.com>
date Mon, 09 Mar 2009 00:14:37 +0000
parents 2033d45a5b99
children c06f02a5e962
line wrap: on
line diff
--- a/Lib/importlib/_bootstrap.py	Mon Mar 09 00:09:44 2009 +0000
+++ b/Lib/importlib/_bootstrap.py	Mon Mar 09 00:14:37 2009 +0000
@@ -383,9 +383,16 @@
     def load_module(self, module):
         """Load a module from source or bytecode."""
         name = module.__name__
-        source_path = self.source_path(name)
-        bytecode_path = self.bytecode_path(name)
-        module.__file__ = source_path if source_path else bytecode_path
+        try:
+            source_path = self.source_path(name)
+        except ImportError:
+            source_path = None
+        try:
+            bytecode_path = self.bytecode_path(name)
+        except ImportError:
+            bytecode_path = None
+        # get_code can worry about no viable paths existing.
+        module.__file__ = source_path or bytecode_path
         return self._load_module(module)
 
     def get_code(self, fullname):