summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/importlib.rst13
-rw-r--r--Doc/library/inspect.rst15
2 files changed, 24 insertions, 4 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index cea2da0..daf9e56 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -533,12 +533,23 @@ find and load modules.
.. attribute:: EXTENSION_SUFFIXES
- A list of strings representing the the recognized file suffixes for
+ A list of strings representing the recognized file suffixes for
extension modules.
.. versionadded:: 3.3
+.. func:: all_suffixes()
+
+ Returns a combined list of strings representing all file suffixes for
+ Python modules recognized by the standard import machinery. This is a
+ helper for code which simply needs to know if a filesystem path
+ potentially represents a Python module (for example,
+ :func:`inspect.getmodulename`)
+
+ .. versionadded:: 3.3
+
+
.. class:: BuiltinImporter
An :term:`importer` for built-in modules. All known built-in modules are
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 6568e94..ac0d6e6 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -198,9 +198,18 @@ attributes:
.. function:: getmodulename(path)
Return the name of the module named by the file *path*, without including the
- names of enclosing packages. This uses the same algorithm as the interpreter
- uses when searching for modules. If the name cannot be matched according to the
- interpreter's rules, ``None`` is returned.
+ names of enclosing packages. The file extension is checked against all of
+ the entries in :func:`importlib.machinery.all_suffixes`. If it matches,
+ the final path component is returned with the extension removed.
+ Otherwise, ``None`` is returned.
+
+ Note that this function *only* returns a meaningful name for actual
+ Python modules - paths that potentially refer to Python packages will
+ still return ``None``.
+
+ .. versionchanged:: 3.3
+ This function is now based directly on :mod:`importlib` rather than the
+ deprecated :func:`getmoduleinfo`.
.. function:: ismodule(object)