]> granicus.if.org Git - python/commitdiff
Issue #13248: Remove inspect.getmoduleinfo() from 3.6 (deprecated in 3.3)
authorYury Selivanov <yselivanov@sprymix.com>
Thu, 23 Jul 2015 14:49:00 +0000 (17:49 +0300)
committerYury Selivanov <yselivanov@sprymix.com>
Thu, 23 Jul 2015 14:49:00 +0000 (17:49 +0300)
Doc/library/inspect.rst
Doc/whatsnew/3.6.rst
Lib/inspect.py

index b5c4a7aac0960a0fe973a9319781d99ef047a5fa..1d0edeadb0115ef455558137f7282624673527a0 100644 (file)
@@ -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)
index b6388d59734ac6a18e33ffd3d3d85dfa15b01bfc..c881d30982502aa55a6fe013de122b5054169d36 100644 (file)
@@ -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
 =====================
index 4e78d80cf549ef2e6c260260cfe87cf5164fd465..305aafe6ed78f6f87f9762fda10e260db6306ef2 100644 (file)
@@ -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)