]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 20438: Deprecate inspect.getargspec() and friends.
authorYury Selivanov <yselivanov@sprymix.com>
Fri, 22 May 2015 15:38:38 +0000 (11:38 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Fri, 22 May 2015 15:38:38 +0000 (11:38 -0400)
Doc/library/inspect.rst
Lib/inspect.py
Lib/test/test_inspect.py

index 831882550a7b9b335e1e56dd2b05698f8c21dc20..6543da974d59cb19c3f88f94b1bd66eff8432b49 100644 (file)
@@ -815,15 +815,16 @@ Classes and functions
 
    The first four items in the tuple correspond to :func:`getargspec`.
 
-   .. note::
-      Consider using the new :ref:`Signature Object <inspect-signature-object>`
-      interface, which provides a better way of introspecting functions.
-
    .. versionchanged:: 3.4
       This function is now based on :func:`signature`, but still ignores
       ``__wrapped__`` attributes and includes the already bound first
       parameter in the signature output for bound methods.
 
+   .. deprecated:: 3.5
+      Use :func:`signature` and
+      :ref:`Signature Object <inspect-signature-object>`, which provide a
+      better introspecting API for callables.
+
 
 .. function:: getargvalues(frame)
 
@@ -896,8 +897,8 @@ Classes and functions
 
    .. versionadded:: 3.2
 
-   .. note::
-      Consider using the new :meth:`Signature.bind` instead.
+   .. deprecated:: 3.5
+      Use :meth:`Signature.bind` and :meth:`Signature.bind_partial` instead.
 
 
 .. function:: getclosurevars(func)
index cbf38e7d1813c919c5552ca37c43a72b4cbbc885..48354f6d618ca2caaedb9b261b26ab3d2e56c39f 100644 (file)
@@ -1033,7 +1033,8 @@ def getargspec(func):
     and keyword arguments are supported. getargspec() will raise ValueError
     if the func has either annotations or keyword arguments.
     """
-
+    warnings.warn("inspect.getargspec() is deprecated, "
+                  "use inspect.signature() instead", DeprecationWarning)
     args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
         getfullargspec(func)
     if kwonlyargs or ann:
@@ -1057,6 +1058,8 @@ def getfullargspec(func):
     'annotations' is a dictionary mapping argument names to annotations.
 
     The first four items in the tuple correspond to getargspec().
+
+    This function is deprecated, use inspect.signature() instead.
     """
 
     try:
index 44405ee97edc13db3d33a580f1fa13cfc433f235..9492cadf09689fca6a7b02b46c1014a6ccd50c66 100644 (file)
@@ -631,7 +631,8 @@ class TestClassesAndFunctions(unittest.TestCase):
 
     def assertArgSpecEquals(self, routine, args_e, varargs_e=None,
                             varkw_e=None, defaults_e=None, formatted=None):
-        args, varargs, varkw, defaults = inspect.getargspec(routine)
+        with self.assertWarns(DeprecationWarning):
+            args, varargs, varkw, defaults = inspect.getargspec(routine)
         self.assertEqual(args, args_e)
         self.assertEqual(varargs, varargs_e)
         self.assertEqual(varkw, varkw_e)