diff -r f23533fa6afa Doc/library/inspect.rst --- a/Doc/library/inspect.rst Thu May 21 20:54:48 2015 +0300 +++ b/Doc/library/inspect.rst Thu May 21 14:55:05 2015 -0400 @@ -817,15 +817,16 @@ The first four items in the tuple correspond to :func:`getargspec`. - .. note:: - Consider using the new :ref:`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 `, which provide a + better introspecting API for callables. + .. function:: getargvalues(frame) @@ -898,8 +899,8 @@ .. 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) diff -r f23533fa6afa Lib/inspect.py --- a/Lib/inspect.py Thu May 21 20:54:48 2015 +0300 +++ b/Lib/inspect.py Thu May 21 14:55:05 2015 -0400 @@ -1033,7 +1033,8 @@ 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 @@ '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: diff -r f23533fa6afa Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Thu May 21 20:54:48 2015 +0300 +++ b/Lib/test/test_inspect.py Thu May 21 14:55:05 2015 -0400 @@ -1,5 +1,6 @@ import builtins import collections +import contextlib import datetime import functools import importlib @@ -89,6 +90,12 @@ yield return 'spam' +@contextlib.contextmanager +def silence_deprecation_warning(): + with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=DeprecationWarning) + yield + class TestPredicates(IsTestBase): def test_eightteen(self): @@ -631,7 +638,8 @@ 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 silence_deprecation_warning(): + args, varargs, varkw, defaults = inspect.getargspec(routine) self.assertEqual(args, args_e) self.assertEqual(varargs, varargs_e) self.assertEqual(varkw, varkw_e)