summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-03-09 00:14:37 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-03-09 00:14:37 (GMT)
commit29dff8aada8b9203a9a37474c9c1163135c8e2f6 (patch)
treeca0a5363d681b54ff64b13a1f853f51e9bfaf832 /Lib/importlib/_bootstrap.py
parent9fd459a3a2ffed7bda16a96c46d2cbca448a5867 (diff)
downloadcpython-29dff8aada8b9203a9a37474c9c1163135c8e2f6.zip
cpython-29dff8aada8b9203a9a37474c9c1163135c8e2f6.tar.gz
cpython-29dff8aada8b9203a9a37474c9c1163135c8e2f6.tar.bz2
Fix importlib._bootstrap.PyPycLoader.load_module() to better handle
source/bytecode paths and what to do when they don't exist.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index b5f08eb..c294490 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -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):