Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,10 @@ def getargspec(func):
Alternatively, use getfullargspec() for an API with a similar namedtuple
based interface, but full support for annotations and keyword-only
parameters.

Deprecated since Python 3.5, use `inspect.getfullargspec()`.
"""
warnings.warn("inspect.getargspec() is deprecated, "
warnings.warn("inspect.getargspec() is deprecated since Python 3.0, "
"use inspect.signature() or inspect.getfullargspec()",
DeprecationWarning, stacklevel=2)
args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
Expand Down Expand Up @@ -2784,19 +2786,25 @@ def __init__(self, parameters=None, *, return_annotation=_empty,

@classmethod
def from_function(cls, func):
"""Constructs Signature for the given python function."""
"""Constructs Signature for the given python function.

Deprecated since Python 3.5, use `Signature.from_callable()`.
"""

warnings.warn("inspect.Signature.from_function() is deprecated, "
"use Signature.from_callable()",
warnings.warn("inspect.Signature.from_function() is deprecated since "
"Python 3.5, use Signature.from_callable()",
DeprecationWarning, stacklevel=2)
return _signature_from_function(cls, func)

@classmethod
def from_builtin(cls, func):
"""Constructs Signature for the given builtin function."""
"""Constructs Signature for the given builtin function.

Deprecated since Python 3.5, use `Signature.from_callable()`.
"""

warnings.warn("inspect.Signature.from_builtin() is deprecated, "
"use Signature.from_callable()",
warnings.warn("inspect.Signature.from_builtin() is deprecated since "
"Python 3.5, use Signature.from_callable()",
DeprecationWarning, stacklevel=2)
return _signature_from_builtin(cls, func)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Document ``getargspec``, ``from_function`` and ``from_builtin`` as
deprecated in their respective docstring, and include version since
deprecation in DeprecationWarning message.