[Python-checkins] r57177 - sandbox/trunk/import_in_py/_importlib.py
brett.cannon
python-checkins at python.org
Sat Aug 18 10:43:29 CEST 2007
Author: brett.cannon
Date: Sat Aug 18 10:43:29 2007
New Revision: 57177
Modified:
sandbox/trunk/import_in_py/_importlib.py
Log:
Store the paths to the source and/or bytecode when the source loader is
initialized.
Modified: sandbox/trunk/import_in_py/_importlib.py
==============================================================================
--- sandbox/trunk/import_in_py/_importlib.py (original)
+++ sandbox/trunk/import_in_py/_importlib.py Sat Aug 18 10:43:29 2007
@@ -372,37 +372,33 @@
self._path = path
self._is_pkg = is_pkg
# Figure out whether source and/or bytecode exists.
- source_exists, bytecode_exists = None, None
for suffix in suffix_list(imp.PY_SOURCE):
if self._path.endswith(suffix):
# Source was found, but we don't know about the bytecode as the
# importer guarantees to check for source first.
- source_exists = True
self._source_path = self._path
base_path = self._path[:len(suffix)]
for suffix in suffix_list(imp.PY_COMPILED):
bytecode_path = base_path + suffix
if _path_exists(bytecode_path):
- bytecode_exists = True
self._bytecode_path = bytecode_path
break
- else:
- # Source was found, but no corresponding bytecode exists.
- bytecode_exists = False
+ # Source was found, but no corresponding bytecode exists.
# Since source was found, the loop should be stopped.
break
else:
# The loader is being asked to load a bytecode file since it was
# not asked to load a source file and that is searched for first.
- source_exists = False
- bytecode_exists = True
+ self._bytecode_path = self._path
@check_name
def load_module(self, fullname):
"""Load a Python source or bytecode file."""
try:
- return self._handler(fullname, self._path, source_exists,
- bytecode_exists, self._is_pkg)
+ return self._handler(fullname, self._path,
+ hasattr(self, '_source_path'),
+ hasattr(self, '_bytecode_path'),
+ self._is_pkg)
except:
# Don't leave a partially initialized module in sys.modules.
if fullname in sys.modules:
More information about the Python-checkins
mailing list