[Python-checkins] cpython (3.3): [issue19152] Add ExtensionFileLoader.get_filename().
eric.snow
python-checkins at python.org
Thu Oct 3 21:53:21 CEST 2013
http://hg.python.org/cpython/rev/832579dbafd6
changeset: 85946:832579dbafd6
branch: 3.3
user: Eric Snow <ericsnowcurrently at gmail.com>
date: Thu Oct 03 12:08:55 2013 -0600
summary:
[issue19152] Add ExtensionFileLoader.get_filename().
files:
Doc/library/importlib.rst | 6 +-
Lib/importlib/_bootstrap.py | 5 +
Lib/importlib/abc.py | 2 +
Misc/NEWS | 2 +
Python/importlib.h | 402 ++++++++++++-----------
5 files changed, 224 insertions(+), 193 deletions(-)
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -800,7 +800,7 @@
.. 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 @@
Returns ``None`` as extension modules do not have source code.
+ .. method:: get_filename(fullname)
+
+ Returns :attr:`path`.
+
:mod:`importlib.util` -- Utility code for importers
---------------------------------------------------
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1153,6 +1153,11 @@
"""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
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
--- a/Lib/importlib/abc.py
+++ b/Lib/importlib/abc.py
@@ -168,6 +168,8 @@
set to."""
raise NotImplementedError
+_register(machinery.ExtensionFileLoader)
+
class FileLoader(_bootstrap.FileLoader, ResourceLoader, ExecutionLoader):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -206,6 +206,8 @@
- 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
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list