summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/inspect.rst21
-rw-r--r--Doc/whatsnew/3.6.rst4
-rw-r--r--Lib/inspect.py17
3 files changed, 5 insertions, 37 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index b5c4a7a..1d0edea 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -227,24 +227,6 @@ attributes:
listed in the metaclass' custom :meth:`__dir__`.
-.. function:: getmoduleinfo(path)
-
- Returns a :term:`named tuple` ``ModuleInfo(name, suffix, mode, module_type)``
- of values that describe how Python will interpret the file identified by
- *path* if it is a module, or ``None`` if it would not be identified as a
- module. In that tuple, *name* is the name of the module without the name of
- any enclosing package, *suffix* is the trailing part of the file name (which
- may not be a dot-delimited extension), *mode* is the :func:`open` mode that
- would be used (``'r'`` or ``'rb'``), and *module_type* is an integer giving
- the type of the module. *module_type* will have a value which can be
- compared to the constants defined in the :mod:`imp` module; see the
- documentation for that module for more information on module types.
-
- .. deprecated:: 3.3
- You may check the file path's suffix against the supported suffixes
- listed in :mod:`importlib.machinery` to infer the same information.
-
-
.. function:: getmodulename(path)
Return the name of the module named by the file *path*, without including the
@@ -258,8 +240,7 @@ attributes:
still return ``None``.
.. versionchanged:: 3.3
- This function is now based directly on :mod:`importlib` rather than the
- deprecated :func:`getmoduleinfo`.
+ The function is based directly on :mod:`importlib`.
.. function:: ismodule(object)
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
index b6388d5..c881d30 100644
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -148,6 +148,10 @@ API and Feature Removals
* ``inspect.getargspec()`` was removed (was deprecated since CPython 3.0).
:func:`inspect.getfullargspec` is an almost drop in replacement.
+* ``inspect.getmoduleinfo`` was removed (was deprecated since CPython 3.3).
+ :func:`inspect.getmodulename` should be used for obtaining the module
+ name for a given path.
+
Porting to Python 3.6
=====================
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 4e78d80..305aafe 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -623,23 +623,6 @@ def getfile(object):
raise TypeError('{!r} is not a module, class, method, '
'function, traceback, frame, or code object'.format(object))
-ModuleInfo = namedtuple('ModuleInfo', 'name suffix mode module_type')
-
-def getmoduleinfo(path):
- """Get the module name, suffix, mode, and module type for a given file."""
- warnings.warn('inspect.getmoduleinfo() is deprecated', DeprecationWarning,
- 2)
- with warnings.catch_warnings():
- warnings.simplefilter('ignore', PendingDeprecationWarning)
- import imp
- filename = os.path.basename(path)
- suffixes = [(-len(suffix), suffix, mode, mtype)
- for suffix, mode, mtype in imp.get_suffixes()]
- suffixes.sort() # try longest suffixes first, in case they overlap
- for neglen, suffix, mode, mtype in suffixes:
- if filename[neglen:] == suffix:
- return ModuleInfo(filename[:neglen], suffix, mode, mtype)
-
def getmodulename(path):
"""Return the module name for a given file, or None."""
fname = os.path.basename(path)