summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-11-22 19:52:36 (GMT)
committerBrett Cannon <brett@python.org>2013-11-22 19:52:36 (GMT)
commit224b26125818056f5d38e2806a1c26fd91ab869c (patch)
treeef634b0d63188444aa5cdcf3cd35bba9869443ed /Lib/importlib/_bootstrap.py
parent873d1226b7cd42c663a4e09fa43a561de2e9f463 (diff)
downloadcpython-224b26125818056f5d38e2806a1c26fd91ab869c.zip
cpython-224b26125818056f5d38e2806a1c26fd91ab869c.tar.gz
cpython-224b26125818056f5d38e2806a1c26fd91ab869c.tar.bz2
User the repr for a module name in more places
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 01fe4ff..235e242 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -526,7 +526,7 @@ def _requires_builtin(fxn):
"""Decorator to verify the named module is built-in."""
def _requires_builtin_wrapper(self, fullname):
if fullname not in sys.builtin_module_names:
- raise ImportError('{} is not a built-in module'.format(fullname),
+ raise ImportError('{!r} is not a built-in module'.format(fullname),
name=fullname)
return fxn(self, fullname)
_wrap(_requires_builtin_wrapper, fxn)
@@ -537,7 +537,7 @@ def _requires_frozen(fxn):
"""Decorator to verify the named module is frozen."""
def _requires_frozen_wrapper(self, fullname):
if not _imp.is_frozen(fullname):
- raise ImportError('{} is not a frozen module'.format(fullname),
+ raise ImportError('{!r} is not a frozen module'.format(fullname),
name=fullname)
return fxn(self, fullname)
_wrap(_requires_frozen_wrapper, fxn)
@@ -1117,7 +1117,7 @@ class _SpecMethods:
_imp.acquire_lock()
with _ModuleLockManager(name):
if sys.modules.get(name) is not module:
- msg = 'module {} not in sys.modules'.format(name)
+ msg = 'module {!r} not in sys.modules'.format(name)
raise ImportError(msg, name=name)
if self.spec.loader is None:
if self.spec.submodule_search_locations is None:
@@ -1247,7 +1247,7 @@ class BuiltinImporter:
spec = module.__spec__
name = spec.name
if not _imp.is_builtin(name):
- raise ImportError('{} is not a built-in module'.format(name),
+ raise ImportError('{!r} is not a built-in module'.format(name),
name=name)
_call_with_frames_removed(_imp.init_builtin, name)
# Have to manually initialize attributes since init_builtin() is not
@@ -1310,7 +1310,7 @@ class FrozenImporter:
def exec_module(module):
name = module.__spec__.name
if not _imp.is_frozen(name):
- raise ImportError('{} is not a frozen module'.format(name),
+ raise ImportError('{!r} is not a frozen module'.format(name),
name=name)
code = _call_with_frames_removed(_imp.get_frozen_object, name)
exec(code, module.__dict__)
@@ -2127,7 +2127,7 @@ def _find_and_load_unlocked(name, import_):
try:
path = parent_module.__path__
except AttributeError:
- msg = (_ERR_MSG + '; {} is not a package').format(name, parent)
+ msg = (_ERR_MSG + '; {!r} is not a package').format(name, parent)
raise ImportError(msg, name=name)
spec = _find_spec(name, path)
if spec is None: