Skip to content

Commit 3cfec2e

Browse files
committed
Issue 20438: Deprecate inspect.getargspec() and friends.
1 parent 8d006e7 commit 3cfec2e

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Doc/library/inspect.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -815,15 +815,16 @@ Classes and functions
815815

816816
The first four items in the tuple correspond to :func:`getargspec`.
817817

818-
.. note::
819-
Consider using the new :ref:`Signature Object <inspect-signature-object>`
820-
interface, which provides a better way of introspecting functions.
821-
822818
.. versionchanged:: 3.4
823819
This function is now based on :func:`signature`, but still ignores
824820
``__wrapped__`` attributes and includes the already bound first
825821
parameter in the signature output for bound methods.
826822

823+
.. deprecated:: 3.5
824+
Use :func:`signature` and
825+
:ref:`Signature Object <inspect-signature-object>`, which provide a
826+
better introspecting API for callables.
827+
827828

828829
.. function:: getargvalues(frame)
829830

@@ -896,8 +897,8 @@ Classes and functions
896897

897898
.. versionadded:: 3.2
898899

899-
.. note::
900-
Consider using the new :meth:`Signature.bind` instead.
900+
.. deprecated:: 3.5
901+
Use :meth:`Signature.bind` and :meth:`Signature.bind_partial` instead.
901902

902903

903904
.. function:: getclosurevars(func)

Lib/inspect.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,8 @@ def getargspec(func):
10331033
and keyword arguments are supported. getargspec() will raise ValueError
10341034
if the func has either annotations or keyword arguments.
10351035
"""
1036-
1036+
warnings.warn("inspect.getargspec() is deprecated, "
1037+
"use inspect.signature() instead", DeprecationWarning)
10371038
args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
10381039
getfullargspec(func)
10391040
if kwonlyargs or ann:
@@ -1057,6 +1058,8 @@ def getfullargspec(func):
10571058
'annotations' is a dictionary mapping argument names to annotations.
10581059
10591060
The first four items in the tuple correspond to getargspec().
1061+
1062+
This function is deprecated, use inspect.signature() instead.
10601063
"""
10611064

10621065
try:

Lib/test/test_inspect.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,8 @@ class D(B, C): pass
631631

632632
def assertArgSpecEquals(self, routine, args_e, varargs_e=None,
633633
varkw_e=None, defaults_e=None, formatted=None):
634-
args, varargs, varkw, defaults = inspect.getargspec(routine)
634+
with self.assertWarns(DeprecationWarning):
635+
args, varargs, varkw, defaults = inspect.getargspec(routine)
635636
self.assertEqual(args, args_e)
636637
self.assertEqual(varargs, varargs_e)
637638
self.assertEqual(varkw, varkw_e)

0 commit comments

Comments
 (0)