Commit 145cf1f5 authored by Dong-hee Na's avatar Dong-hee Na Committed by Brett Cannon

bpo-35923: Update the BuiltinImporter to use loader._ORIGIN instead of a...

bpo-35923: Update the BuiltinImporter to use loader._ORIGIN instead of a hard-coded value (GH-15651)

parent 1fae8444
...@@ -713,6 +713,8 @@ class BuiltinImporter: ...@@ -713,6 +713,8 @@ class BuiltinImporter:
""" """
_ORIGIN = "built-in"
@staticmethod @staticmethod
def module_repr(module): def module_repr(module):
"""Return repr for the module. """Return repr for the module.
...@@ -720,14 +722,14 @@ class BuiltinImporter: ...@@ -720,14 +722,14 @@ class BuiltinImporter:
The method is deprecated. The import machinery does the job itself. 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 @classmethod
def find_spec(cls, fullname, path=None, target=None): def find_spec(cls, fullname, path=None, target=None):
if path is not None: if path is not None:
return None return None
if _imp.is_builtin(fullname): if _imp.is_builtin(fullname):
return spec_from_loader(fullname, cls, origin='built-in') return spec_from_loader(fullname, cls, origin=cls._ORIGIN)
else: else:
return None return None
......
Update :class:`importlib.machinery.BuiltinImporter` to use ``loader._ORIGIN``
instead of a hardcoded value. Patch by Dong-hee Na.
This diff is collapsed.
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