[Python-checkins] r57268 - sandbox/trunk/import_in_py/_importlib.py
brett.cannon
python-checkins at python.org
Wed Aug 22 00:09:58 CEST 2007
Author: brett.cannon
Date: Wed Aug 22 00:09:57 2007
New Revision: 57268
Modified:
sandbox/trunk/import_in_py/_importlib.py
Log:
Clean up comments and make ImportError exception messages be what was previous
specified.
Modified: sandbox/trunk/import_in_py/_importlib.py
==============================================================================
--- sandbox/trunk/import_in_py/_importlib.py (original)
+++ sandbox/trunk/import_in_py/_importlib.py Wed Aug 22 00:09:57 2007
@@ -306,10 +306,12 @@
try:
return marshal.loads(bytecode), bytecode_path
except ValueError:
- # XXX Does this have to be true?
+ # XXX Is it useful to bail out when the bytecode is bad? Why
+ # not use the source if possible and issue a warning that the
+ # bytecode was bad?
# Since bad bytecode halts the import entirely, having the
- # source code is useless. Signal this fact by setting
- # bytecode_path to None.
+ # source code is useless. Signal this fact by setting
+ # bytecode_path to None.
bytecode_path = None
raise ImportError('Non-code object found')
except ImportError:
@@ -335,8 +337,6 @@
_handler = handle_code
_module_init = init_module
- # XXX Take in fullname from importer to make sure loader is not called for
- # another module?
def __init__(self, name, path, is_pkg):
self._name = name
self._is_pkg = is_pkg
@@ -514,7 +514,6 @@
file_path = _path_join(self._path_entry, file_name)
if (_path_isfile(file_path) and
_case_ok(self._path_entry, file_name)):
- # XXX Pass in importer as well to access attributes?
return self._loader(fullname, file_path, False)
else:
# Raise a warning if it matches a directory w/o an __init__ file.
@@ -626,7 +625,8 @@
# If None was returned, use default importer factory.
if importer is None:
# XXX Would it break backwards-compatibility to set the importer
- # in sys.path_importer_cache, replacing the None entry?
+ # in sys.path_importer_cache, replacing the None entry and not
+ # rely on None being there?
return self.default_path_hook(path_entry)
else:
return importer
@@ -671,7 +671,7 @@
if loader:
return loader
else:
- raise ImportError("No module found named %s" % name)
+ raise ImportError("No module named %s" % name)
def module_from_cache(self, name):
"""Try to return the named module from sys.modules.
More information about the Python-checkins
mailing list