summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-10-20 00:05:49 (GMT)
committerGitHub <noreply@github.com>2018-10-20 00:05:49 (GMT)
commitc8348fb6d2ef1b5bb91d6eb5fbafdf42c4ae16ce (patch)
tree2d20c45676e32a3ce3f86e01f4592d8d1e243a6e
parent0f2fc8bee0b435ee2934751264196db30d16ed8a (diff)
downloadcpython-c8348fb6d2ef1b5bb91d6eb5fbafdf42c4ae16ce.zip
cpython-c8348fb6d2ef1b5bb91d6eb5fbafdf42c4ae16ce.tar.gz
cpython-c8348fb6d2ef1b5bb91d6eb5fbafdf42c4ae16ce.tar.bz2
bpo-33594: Add deprecation info in inspect.py module (GH-7036)
(cherry picked from commit ded87d804e2a85b2a3ea9e7a11384b41fafdfa29) Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
-rw-r--r--Lib/inspect.py22
-rw-r--r--Misc/NEWS.d/next/Documentation/2018-05-21-14-36-12.bpo-33594.-HRcyX.rst3
2 files changed, 18 insertions, 7 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index b5d583c..da4a424 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -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 = \
@@ -2802,19 +2804,25 @@ class Signature:
@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)
diff --git a/Misc/NEWS.d/next/Documentation/2018-05-21-14-36-12.bpo-33594.-HRcyX.rst b/Misc/NEWS.d/next/Documentation/2018-05-21-14-36-12.bpo-33594.-HRcyX.rst
new file mode 100644
index 0000000..a63c4a5
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2018-05-21-14-36-12.bpo-33594.-HRcyX.rst
@@ -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.