[Python-checkins] r57174 - sandbox/trunk/import_in_py/_importlib.py

brett.cannon python-checkins at python.org
Sat Aug 18 05:42:24 CEST 2007


Author: brett.cannon
Date: Sat Aug 18 05:41:18 2007
New Revision: 57174

Modified:
   sandbox/trunk/import_in_py/_importlib.py
Log:
Move source/bytecode discovery for PyFileLoader to __init__ so that the
instance's state does not rely on load_module being called first.


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 05:41:18 2007
@@ -371,10 +371,7 @@
         self._name = name
         self._path = path
         self._is_pkg = is_pkg
-
-    def load_module(self, fullname):
-        """Load a Python source or bytecode file."""
-        assert self._name == fullname
+        # 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):
@@ -399,6 +396,10 @@
             # not asked to load a source file and that is searched for first.
             source_exists = False
             bytecode_exists = True
+
+    @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)


More information about the Python-checkins mailing list