Skip to content

Commit 145cf1f

Browse files
corona10brettcannon
authored andcommitted
bpo-35923: Update the BuiltinImporter to use loader._ORIGIN instead of a hard-coded value (GH-15651)
1 parent 1fae844 commit 145cf1f

File tree

3 files changed

+761
-756
lines changed

3 files changed

+761
-756
lines changed

Lib/importlib/_bootstrap.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,21 +713,23 @@ class BuiltinImporter:
713713
714714
"""
715715

716+
_ORIGIN = "built-in"
717+
716718
@staticmethod
717719
def module_repr(module):
718720
"""Return repr for the module.
719721
720722
The method is deprecated. The import machinery does the job itself.
721723
722724
"""
723-
return '<module {!r} (built-in)>'.format(module.__name__)
725+
return f'<module {module.__name__!r} ({BuiltinImporter._ORIGIN})>'
724726

725727
@classmethod
726728
def find_spec(cls, fullname, path=None, target=None):
727729
if path is not None:
728730
return None
729731
if _imp.is_builtin(fullname):
730-
return spec_from_loader(fullname, cls, origin='built-in')
732+
return spec_from_loader(fullname, cls, origin=cls._ORIGIN)
731733
else:
732734
return None
733735

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Update :class:`importlib.machinery.BuiltinImporter` to use ``loader._ORIGIN``
2+
instead of a hardcoded value. Patch by Dong-hee Na.

0 commit comments

Comments
 (0)