[Python-checkins] cpython: Issue #13248: Remove inspect.getmoduleinfo() from 3.6 (deprecated in 3.3)

yury.selivanov python-checkins at python.org
Thu Jul 23 16:49:35 CEST 2015


https://hg.python.org/cpython/rev/558199e060fd
changeset:   97024:558199e060fd
user:        Yury Selivanov <yselivanov at sprymix.com>
date:        Thu Jul 23 17:49:00 2015 +0300
summary:
  Issue #13248: Remove inspect.getmoduleinfo() from 3.6 (deprecated in 3.3)

files:
  Doc/library/inspect.rst |  21 +--------------------
  Doc/whatsnew/3.6.rst    |   4 ++++
  Lib/inspect.py          |  17 -----------------
  3 files changed, 5 insertions(+), 37 deletions(-)


diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -227,24 +227,6 @@
       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 @@
    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
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -148,6 +148,10 @@
 * ``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
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -623,23 +623,6 @@
     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)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list