From a7468bc5c6153784fb9ab35baf030162208d852d Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 23 Mar 2011 16:06:00 -0700 Subject: [PATCH] Have importlib use the repr of a module name in error messages. 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 | 2 +- Misc/NEWS | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index a944bee862a..f2ef1cf714c 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index a6ae16a7b65..0dd8a3d58e0 100644 --- 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.