Fix a minor inconsistency in capitalization for the 'No module named' exception

message in importlib.

Thanks to Éric Araujo for spotting the inconsistency.
This commit is contained in:
Brett Cannon 2010-11-18 03:03:04 +00:00
parent 8fb9b868bd
commit 0ffe6a9760
2 changed files with 7 additions and 3 deletions

View File

@ -758,6 +758,8 @@ class _ImportLockContext:
_IMPLICIT_META_PATH = [BuiltinImporter, FrozenImporter, _DefaultPathFinder] _IMPLICIT_META_PATH = [BuiltinImporter, FrozenImporter, _DefaultPathFinder]
_ERR_MSG = 'No module named {}'
def _gcd_import(name, package=None, level=0): def _gcd_import(name, package=None, level=0):
"""Import and return the module based on its name, the package the call is """Import and return the module based on its name, the package the call is
being made from, and the level adjustment. being made from, and the level adjustment.
@ -808,8 +810,8 @@ def _gcd_import(name, package=None, level=0):
try: try:
path = parent_module.__path__ path = parent_module.__path__
except AttributeError: except AttributeError:
raise ImportError("no module named {}; " msg = (_ERR_MSG + '; {} is not a package').format(name, parent)
"{} is not a package".format(name, parent)) raise ImportError(msg)
meta_path = sys.meta_path + _IMPLICIT_META_PATH meta_path = sys.meta_path + _IMPLICIT_META_PATH
for finder in meta_path: for finder in meta_path:
loader = finder.find_module(name, path) loader = finder.find_module(name, path)
@ -817,7 +819,7 @@ def _gcd_import(name, package=None, level=0):
loader.load_module(name) loader.load_module(name)
break break
else: else:
raise ImportError("No module named {0}".format(name)) raise ImportError(_ERR_MSG.format(name))
# Backwards-compatibility; be nicer to skip the dict lookup. # Backwards-compatibility; be nicer to skip the dict lookup.
module = sys.modules[name] module = sys.modules[name]
if parent: if parent:

View File

@ -18,6 +18,8 @@ Core and Builtins
Library Library
------- -------
- Make the 'No module named' exception message from importlib consistent.
- Issue #10443: Add the SSLContext.set_default_verify_paths() method. - Issue #10443: Add the SSLContext.set_default_verify_paths() method.
- Issue #10440: Support RUSAGE_THREAD as a constant in the resource module. - Issue #10440: Support RUSAGE_THREAD as a constant in the resource module.