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

brett.cannon python-checkins at python.org
Sat Aug 18 01:43:37 CEST 2007


Author: brett.cannon
Date: Sat Aug 18 01:43:33 2007
New Revision: 57168

Modified:
   sandbox/trunk/import_in_py/_importlib.py
Log:
Make the source handler something that can be set on the loader object.


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 01:43:33 2007
@@ -271,8 +271,17 @@
             if suffix[2] == suffix_type]
 
 
+def handle_py(loader, name, path, source_exists, bytecode_exists, is_pkg):
+    """Handle the initialization of a module by Python source or bytecode."""
+    raise NotImplementedError
+
+
 class _PyFileLoader(object):
 
+    """Load a Python source or bytecode file."""
+
+    _handler = handle_py
+
     # XXX Take in fullname from importer to make sure loader is not called for
     # another module?
     def __init__(self, name, path, is_pkg):
@@ -308,7 +317,7 @@
             source_exists = False
             bytecode_exists = True
         try:
-            return handle_py(self, fullname, self_path, source_exists,
+            return self._handler(fullname, self_path, source_exists,
                              bytecode_exists, self_is_pkg)
         except:
             # Don't leave a partially initialized module in sys.modules.


More information about the Python-checkins mailing list