[Python-checkins] r56980 - sandbox/trunk/import_in_py/_importlib.py
brett.cannon
python-checkins at python.org
Mon Aug 13 10:00:22 CEST 2007
Author: brett.cannon
Date: Mon Aug 13 10:00:21 2007
New Revision: 56980
Modified:
sandbox/trunk/import_in_py/_importlib.py
Log:
Fix import issues thanks to not being to rely on class init that is dependent
on injected modules.
Modified: sandbox/trunk/import_in_py/_importlib.py
==============================================================================
--- sandbox/trunk/import_in_py/_importlib.py (original)
+++ sandbox/trunk/import_in_py/_importlib.py Mon Aug 13 10:00:21 2007
@@ -268,9 +268,10 @@
if suffix[2] in self._file_types]
def find_module(self, fullname, path=None):
- tail_module = name.rsplit('.', 1)[-1]
+ tail_module = fullname.rsplit('.', 1)[-1]
# XXX Do we need to check for packages first with all possible file
- # extensions and then check for files?
+ # extensions and then check for files (e.g., check for __init__.py
+ # and __init__.pyc first, and then look for a submodule.
for ext in self._suffixes:
if self._possible_package:
package_directory = _path_join(self._path_entry, tail_module)
@@ -295,23 +296,38 @@
return None
+# XXX Placeholder
+class ExtensionFileLoader(object):
+ pass
+class PyFileLoader(object):
+ pass
+
+
class ExtensionFileImporter(FileImporter):
"""Importer for extension files."""
- _file_types = [imp.C_EXTENSION]
_possible_package = False
_loader = ExtensionFileLoader
+ def __init__(self, path_entry):
+ self._file_types = [imp.C_EXTENSION]
+ super(self.__class__, self).__init__(path_entry)
+
class PyFileImporter(FileImporter):
"""Importer for source/bytecode files."""
- _file_types = [imp.PY_SOURCE, imp.PY_COMPILED]
_possible_package = True
_loader = PyFileLoader
+ def __init__(self, path_entry):
+ self._file_types = [imp.PY_SOURCE, imp.PY_COMPILED]
+ super(self.__class__, self).__init__(path_entry)
+
+
+
class FileSystemImporter(object):
More information about the Python-checkins
mailing list