mirror of
https://github.com/python/cpython.git
synced 2025-07-22 18:55:22 +00:00
Issue 20438: Deprecate inspect.getargspec() and friends.
This commit is contained in:
parent
8d006e75e0
commit
3cfec2e2fc
3 changed files with 13 additions and 8 deletions
|
@ -815,15 +815,16 @@ Classes and functions
|
||||||
|
|
||||||
The first four items in the tuple correspond to :func:`getargspec`.
|
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
|
.. versionchanged:: 3.4
|
||||||
This function is now based on :func:`signature`, but still ignores
|
This function is now based on :func:`signature`, but still ignores
|
||||||
``__wrapped__`` attributes and includes the already bound first
|
``__wrapped__`` attributes and includes the already bound first
|
||||||
parameter in the signature output for bound methods.
|
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)
|
.. function:: getargvalues(frame)
|
||||||
|
|
||||||
|
@ -896,8 +897,8 @@ Classes and functions
|
||||||
|
|
||||||
.. versionadded:: 3.2
|
.. versionadded:: 3.2
|
||||||
|
|
||||||
.. note::
|
.. deprecated:: 3.5
|
||||||
Consider using the new :meth:`Signature.bind` instead.
|
Use :meth:`Signature.bind` and :meth:`Signature.bind_partial` instead.
|
||||||
|
|
||||||
|
|
||||||
.. function:: getclosurevars(func)
|
.. function:: getclosurevars(func)
|
||||||
|
|
|
@ -1033,7 +1033,8 @@ def getargspec(func):
|
||||||
and keyword arguments are supported. getargspec() will raise ValueError
|
and keyword arguments are supported. getargspec() will raise ValueError
|
||||||
if the func has either annotations or keyword arguments.
|
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 = \
|
args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
|
||||||
getfullargspec(func)
|
getfullargspec(func)
|
||||||
if kwonlyargs or ann:
|
if kwonlyargs or ann:
|
||||||
|
@ -1057,6 +1058,8 @@ def getfullargspec(func):
|
||||||
'annotations' is a dictionary mapping argument names to annotations.
|
'annotations' is a dictionary mapping argument names to annotations.
|
||||||
|
|
||||||
The first four items in the tuple correspond to getargspec().
|
The first four items in the tuple correspond to getargspec().
|
||||||
|
|
||||||
|
This function is deprecated, use inspect.signature() instead.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -631,6 +631,7 @@ class TestClassesAndFunctions(unittest.TestCase):
|
||||||
|
|
||||||
def assertArgSpecEquals(self, routine, args_e, varargs_e=None,
|
def assertArgSpecEquals(self, routine, args_e, varargs_e=None,
|
||||||
varkw_e=None, defaults_e=None, formatted=None):
|
varkw_e=None, defaults_e=None, formatted=None):
|
||||||
|
with self.assertWarns(DeprecationWarning):
|
||||||
args, varargs, varkw, defaults = inspect.getargspec(routine)
|
args, varargs, varkw, defaults = inspect.getargspec(routine)
|
||||||
self.assertEqual(args, args_e)
|
self.assertEqual(args, args_e)
|
||||||
self.assertEqual(varargs, varargs_e)
|
self.assertEqual(varargs, varargs_e)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue