Skip to content

Commit 932ebc1

Browse files
bpo-33594: Add deprecation info in inspect.py module (GH-7036)
(cherry picked from commit ded87d8) Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
1 parent 70102ff commit 932ebc1

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

Lib/inspect.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,10 @@ def getargspec(func):
10701070
Alternatively, use getfullargspec() for an API with a similar namedtuple
10711071
based interface, but full support for annotations and keyword-only
10721072
parameters.
1073+
1074+
Deprecated since Python 3.5, use `inspect.getfullargspec()`.
10731075
"""
1074-
warnings.warn("inspect.getargspec() is deprecated, "
1076+
warnings.warn("inspect.getargspec() is deprecated since Python 3.0, "
10751077
"use inspect.signature() or inspect.getfullargspec()",
10761078
DeprecationWarning, stacklevel=2)
10771079
args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
@@ -2784,19 +2786,25 @@ def __init__(self, parameters=None, *, return_annotation=_empty,
27842786

27852787
@classmethod
27862788
def from_function(cls, func):
2787-
"""Constructs Signature for the given python function."""
2789+
"""Constructs Signature for the given python function.
2790+
2791+
Deprecated since Python 3.5, use `Signature.from_callable()`.
2792+
"""
27882793

2789-
warnings.warn("inspect.Signature.from_function() is deprecated, "
2790-
"use Signature.from_callable()",
2794+
warnings.warn("inspect.Signature.from_function() is deprecated since "
2795+
"Python 3.5, use Signature.from_callable()",
27912796
DeprecationWarning, stacklevel=2)
27922797
return _signature_from_function(cls, func)
27932798

27942799
@classmethod
27952800
def from_builtin(cls, func):
2796-
"""Constructs Signature for the given builtin function."""
2801+
"""Constructs Signature for the given builtin function.
2802+
2803+
Deprecated since Python 3.5, use `Signature.from_callable()`.
2804+
"""
27972805

2798-
warnings.warn("inspect.Signature.from_builtin() is deprecated, "
2799-
"use Signature.from_callable()",
2806+
warnings.warn("inspect.Signature.from_builtin() is deprecated since "
2807+
"Python 3.5, use Signature.from_callable()",
28002808
DeprecationWarning, stacklevel=2)
28012809
return _signature_from_builtin(cls, func)
28022810

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Document ``getargspec``, ``from_function`` and ``from_builtin`` as
2+
deprecated in their respective docstring, and include version since
3+
deprecation in DeprecationWarning message.

0 commit comments

Comments
 (0)