]> granicus.if.org Git - python/commitdiff
Fix importlib._bootstrap.PyPycLoader.load_module() to better handle
authorBrett Cannon <bcannon@gmail.com>
Mon, 9 Mar 2009 00:14:37 +0000 (00:14 +0000)
committerBrett Cannon <bcannon@gmail.com>
Mon, 9 Mar 2009 00:14:37 +0000 (00:14 +0000)
source/bytecode paths and what to do when they don't exist.

Lib/importlib/_bootstrap.py

index b5f08eb84ad69b9dff5f81e5d1057e4fbe2a1ffa..c2944903374b3cdd308cc4f69201a616448f7081 100644 (file)
@@ -383,9 +383,16 @@ class PyPycLoader(PyLoader):
     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):