Kaydet (Commit) af8566c8 authored tarafından Eric Snow's avatar Eric Snow

[issue19152] Add ExtensionFileLoader.get_filename().

üst efbc4752
......@@ -800,7 +800,7 @@ find and load modules.
.. class:: ExtensionFileLoader(fullname, path)
A concrete implementation of :class:`importlib.abc.InspectLoader` for
A concrete implementation of :class:`importlib.abc.ExecutionLoader` for
extension modules.
The *fullname* argument specifies the name of the module the loader is to
......@@ -834,6 +834,10 @@ find and load modules.
Returns ``None`` as extension modules do not have source code.
.. method:: get_filename(fullname)
Returns :attr:`path`.
:mod:`importlib.util` -- Utility code for importers
---------------------------------------------------
......
......@@ -1153,6 +1153,11 @@ class ExtensionFileLoader:
"""Return None as extension modules have no source code."""
return None
@_check_name
def get_filename(self, fullname):
"""Return the path to the source file as found by the finder."""
return self.path
class _NamespacePath:
"""Represents a namespace package's path. It uses the module name
......
......@@ -168,6 +168,8 @@ class ExecutionLoader(InspectLoader):
set to."""
raise NotImplementedError
_register(machinery.ExtensionFileLoader)
class FileLoader(_bootstrap.FileLoader, ResourceLoader, ExecutionLoader):
......
......@@ -206,6 +206,8 @@ Library
- Issue #19151: Fix docstring and use of _get_suppported_file_loaders() to
reflect 2-tuples.
- Issue #19152: Add ExtensionFileLoader.get_filename().
- Issue #18676: Change 'positive' to 'non-negative' in queue.py put and get
docstrings and ValueError messages. Patch by Zhongyue Luo
......
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