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

brett.cannon python-checkins at python.org
Tue Aug 14 06:13:35 CEST 2007


Author: brett.cannon
Date: Tue Aug 14 06:13:34 2007
New Revision: 57002

Modified:
   sandbox/trunk/import_in_py/_importlib.py
Log:
Have a package searched for first, then a module (untested).


Modified: sandbox/trunk/import_in_py/_importlib.py
==============================================================================
--- sandbox/trunk/import_in_py/_importlib.py	(original)
+++ sandbox/trunk/import_in_py/_importlib.py	Tue Aug 14 06:13:34 2007
@@ -272,8 +272,8 @@
         # XXX Do we need to check for packages first with all possible file
         #     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:
+        if self._possible_package:
+            for ext in self._suffixes:
                 package_directory = _path_join(self._path_entry, tail_module)
                 init_filename = '__init__' + ext
                 package_init = _path_join(package_directory, init_filename)
@@ -281,6 +281,7 @@
                         _case_ok(self._path_entry, tail_module) and
                         _case_ok(package_directory, init_filename)):
                     return self._loader(package_init)
+        for ext in self._suffixes:
             file_name = tail_module + ext
             file_path = _path_join(self._path_entry, file_name)
             if (_path_isfile(file_path) and


More information about the Python-checkins mailing list