[Python-checkins] r86507 - in python/branches/py3k: Lib/importlib/_bootstrap.py Misc/NEWS

brett.cannon python-checkins at python.org
Thu Nov 18 04:03:04 CET 2010


Author: brett.cannon
Date: Thu Nov 18 04:03:04 2010
New Revision: 86507
Log:
Fix a minor inconsistency in capitalization for the 'No module named' exception
message in importlib.
Thanks to Éric Araujo for spotting the inconsistency.
Modified:
 python/branches/py3k/Lib/importlib/_bootstrap.py
 python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Lib/importlib/_bootstrap.py
==============================================================================
--- python/branches/py3k/Lib/importlib/_bootstrap.py	(original)
+++ python/branches/py3k/Lib/importlib/_bootstrap.py	Thu Nov 18 04:03:04 2010
@@ -758,6 +758,8 @@
 
 _IMPLICIT_META_PATH = [BuiltinImporter, FrozenImporter, _DefaultPathFinder]
 
+_ERR_MSG = 'No module named {}'
+
 def _gcd_import(name, package=None, level=0):
 """Import and return the module based on its name, the package the call is
 being made from, and the level adjustment.
@@ -808,8 +810,8 @@
 try:
 path = parent_module.__path__
 except AttributeError:
- raise ImportError("no module named {}; "
- "{} is not a package".format(name, parent))
+ msg = (_ERR_MSG + '; {} is not a package').format(name, parent)
+ raise ImportError(msg)
 meta_path = sys.meta_path + _IMPLICIT_META_PATH
 for finder in meta_path:
 loader = finder.find_module(name, path)
@@ -817,7 +819,7 @@
 loader.load_module(name)
 break
 else:
- raise ImportError("No module named {0}".format(name))
+ raise ImportError(_ERR_MSG.format(name))
 # Backwards-compatibility; be nicer to skip the dict lookup.
 module = sys.modules[name]
 if parent:
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Thu Nov 18 04:03:04 2010
@@ -18,6 +18,8 @@
 Library
 -------
 
+- Make the 'No module named' exception message from importlib consistent.
+
 - Issue #10443: Add the SSLContext.set_default_verify_paths() method.
 
 - Issue #10440: Support RUSAGE_THREAD as a constant in the resource module.


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /