Commit a7468bc5 authored by Brett Cannon's avatar Brett Cannon

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.
parent f3c524d5
...@@ -758,7 +758,7 @@ class _ImportLockContext: ...@@ -758,7 +758,7 @@ class _ImportLockContext:
_IMPLICIT_META_PATH = [BuiltinImporter, FrozenImporter, _DefaultPathFinder] _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): 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
......
...@@ -84,6 +84,8 @@ Core and Builtins ...@@ -84,6 +84,8 @@ Core and Builtins
Library 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 - Issue #11591: Prevent "import site" from modifying sys.path when python
was started with -S. was started with -S.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment