Skip to content

Commit

Permalink
[issue19152] Add ExtensionFileLoader.get_filename().
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Oct 3, 2013
1 parent e8bbfeb commit 5179445
Show file tree
Hide file tree
Showing 5 changed files with 1,376 additions and 1,349 deletions.
6 changes: 5 additions & 1 deletion Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,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
Expand Down Expand Up @@ -870,6 +870,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
---------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions Lib/importlib/_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,11 @@ def get_source(self, fullname):
"""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
Expand Down
2 changes: 2 additions & 0 deletions Lib/importlib/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ def init_module_attrs(self, module):
super().init_module_attrs(module)
_bootstrap._init_file_attrs(self, module)

_register(machinery.ExtensionFileLoader)


class FileLoader(_bootstrap.FileLoader, ResourceLoader, ExecutionLoader):

Expand Down
2 changes: 2 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ Library
- Issue #19951: 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

Expand Down
Loading

0 comments on commit 5179445

Please sign in to comment.