]> granicus.if.org Git - python/commitdiff
Have importlib use the repr of a module name in error messages.
authorBrett Cannon <brett@python.org>
Wed, 23 Mar 2011 23:06:00 +0000 (16:06 -0700)
committerBrett Cannon <brett@python.org>
Wed, 23 Mar 2011 23:06:00 +0000 (16:06 -0700)
This makes it obvious that an import failed because of some extraneous
whitespace (e.g., a newline).

This is a partial fix for issue #8754.

Lib/importlib/_bootstrap.py
Misc/NEWS

index a944bee862aedc56805f073d34a8bdf90498ba13..f2ef1cf714c7dd58e8d2b15cbf19cd696c7fb00b 100644 (file)
@@ -758,7 +758,7 @@ class _ImportLockContext:
 
 _IMPLICIT_META_PATH = [BuiltinImporter, FrozenImporter, _DefaultPathFinder]
 
-_ERR_MSG = 'No module named {}'
+_ERR_MSG = 'No module named {!r}'
 
 def _gcd_import(name, package=None, level=0):
     """Import and return the module based on its name, the package the call is
index a6ae16a7b659c94291d694aba4e504577b4c0894..0dd8a3d58e03a398413ab16f7240a9275d127b1f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -84,6 +84,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #8754: Have importlib use the repr of a module name in error messages.
+
 - Issue #11591: Prevent "import site" from modifying sys.path when python
   was started with -S.