Skip to content

bpo-35923: Update the BuiltinImporter to use loader._ORIGIN #15651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Lib/importlib/_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,21 +713,23 @@ class BuiltinImporter:

"""

_ORIGIN = "built-in"

@staticmethod
def module_repr(module):
"""Return repr for the module.

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update :class:`importlib.machinery.BuiltinImporter` to use ``loader._ORIGIN``
instead of a hardcoded value. Patch by Dong-hee Na.
Loading