summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2019-09-11 16:00:02 (GMT)
committerBrett Cannon <54418+brettcannon@users.noreply.github.com>2019-09-11 16:00:02 (GMT)
commit145cf1f50c8a8e8233e641f345cd5e25ee69190a (patch)
treea34b85110e0ed0bb2f33c4d5d1fc98df13b76990 /Lib/importlib
parent1fae844451b120b93880d9360f288c70e125520c (diff)
downloadcpython-145cf1f50c8a8e8233e641f345cd5e25ee69190a.zip
cpython-145cf1f50c8a8e8233e641f345cd5e25ee69190a.tar.gz
cpython-145cf1f50c8a8e8233e641f345cd5e25ee69190a.tar.bz2
bpo-35923: Update the BuiltinImporter to use loader._ORIGIN instead of a hard-coded value (GH-15651)
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index e17eeb6..8de0e9e 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -713,6 +713,8 @@ class BuiltinImporter:
"""
+ _ORIGIN = "built-in"
+
@staticmethod
def module_repr(module):
"""Return repr for the module.
@@ -720,14 +722,14 @@ class BuiltinImporter:
The method is deprecated. The import machinery does the job itself.
"""
- return '<module {!r} (built-in)>'.format(module.__name__)
+ return f'<module {module.__name__!r} ({BuiltinImporter._ORIGIN})>'
@classmethod
def find_spec(cls, fullname, path=None, target=None):
if path is not None:
return None
if _imp.is_builtin(fullname):
- return spec_from_loader(fullname, cls, origin='built-in')
+ return spec_from_loader(fullname, cls, origin=cls._ORIGIN)
else:
return None