Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ded87d8

Browse files
Carreauvstinner
authored andcommitted
bpo-33594: Add deprecation info in inspect.py module (GH-7036)
1 parent 0f14fc1 commit ded87d8

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 = \
@@ -2797,19 +2799,25 @@ def __init__(self, parameters=None, *, return_annotation=_empty,
27972799

27982800
@classmethod
27992801
def from_function(cls, func):
2800-
"""Constructs Signature for the given python function."""
2802+
"""Constructs Signature for the given python function.
2803+
2804+
Deprecated since Python 3.5, use `Signature.from_callable()`.
2805+
"""
28012806

2802-
warnings.warn("inspect.Signature.from_function() is deprecated, "
2803-
"use Signature.from_callable()",
2807+
warnings.warn("inspect.Signature.from_function() is deprecated since "
2808+
"Python 3.5, use Signature.from_callable()",
28042809
DeprecationWarning, stacklevel=2)
28052810
return _signature_from_function(cls, func)
28062811

28072812
@classmethod
28082813
def from_builtin(cls, func):
2809-
"""Constructs Signature for the given builtin function."""
2814+
"""Constructs Signature for the given builtin function.
2815+
2816+
Deprecated since Python 3.5, use `Signature.from_callable()`.
2817+
"""
28102818

2811-
warnings.warn("inspect.Signature.from_builtin() is deprecated, "
2812-
"use Signature.from_callable()",
2819+
warnings.warn("inspect.Signature.from_builtin() is deprecated since "
2820+
"Python 3.5, use Signature.from_callable()",
28132821
DeprecationWarning, stacklevel=2)
28142822
return _signature_from_builtin(cls, func)
28152823

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)