summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-05-16 20:08:15 (GMT)
committerGitHub <noreply@github.com>2019-05-16 20:08:15 (GMT)
commitaee19f54f6fe45f6b3c906987941e5a8af4468e9 (patch)
treeda9a3967721268606f7199a0effd5cc28ff96c91
parent54b43bb3bb88339b63182b3515cda3efa530ed62 (diff)
downloadcpython-aee19f54f6fe45f6b3c906987941e5a8af4468e9.zip
cpython-aee19f54f6fe45f6b3c906987941e5a8af4468e9.tar.gz
cpython-aee19f54f6fe45f6b3c906987941e5a8af4468e9.tar.bz2
bpo-36751: Undeprecate getfullargspec (GH-13245)
-rw-r--r--Doc/library/inspect.rst5
-rw-r--r--Doc/whatsnew/3.8.rst4
-rw-r--r--Lib/inspect.py6
-rw-r--r--Lib/test/test_inspect.py54
-rw-r--r--Misc/NEWS.d/3.8.0a4.rst11
5 files changed, 20 insertions, 60 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index d12f122..81824dd 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -948,11 +948,6 @@ Classes and functions
APIs. This function is retained primarily for use in code that needs to
maintain compatibility with the Python 2 ``inspect`` module API.
- .. deprecated:: 3.8
- Use :func:`signature` and
- :ref:`Signature Object <inspect-signature-object>`, which provide a
- better introspecting API for callables.
-
.. versionchanged:: 3.4
This function is now based on :func:`signature`, but still ignores
``__wrapped__`` attributes and includes the already bound first
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index c135183..d47993b 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -780,10 +780,6 @@ Deprecated
<positional-only_parameter>`.
(Contributed by Serhiy Storchaka in :issue:`36492`.)
-* The function :func:`~inspect.getfullargspec` in the :mod:`inspect`
- module is deprecated in favor of the :func:`inspect.signature`
- API. (Contributed by Pablo Galindo in :issue:`36751`.)
-
API and Feature Removals
========================
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 6c30279..a4f28f7 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1103,16 +1103,10 @@ def getfullargspec(func):
'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults.
'annotations' is a dictionary mapping parameter names to annotations.
- .. deprecated:: 3.8
- Use inspect.signature() instead of inspect.getfullargspec().
-
Notable differences from inspect.signature():
- the "self" parameter is always reported, even for bound methods
- wrapper chains defined by __wrapped__ *not* unwrapped automatically
"""
-
- warnings.warn("Use inspect.signature() instead of inspect.getfullargspec()",
- DeprecationWarning, stacklevel=2)
try:
# Re: `skip_bound_arg=False`
#
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index c54cdb2..be52b38 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -750,25 +750,22 @@ class TestClassesAndFunctions(unittest.TestCase):
def assertArgSpecEquals(self, routine, args_e, varargs_e=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(varargs, varargs_e)
self.assertEqual(varkw, varkw_e)
self.assertEqual(defaults, defaults_e)
if formatted is not None:
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults),
- formatted)
+ self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults),
+ formatted)
def assertFullArgSpecEquals(self, routine, args_e, varargs_e=None,
varkw_e=None, defaults_e=None,
posonlyargs_e=[], kwonlyargs_e=[],
kwonlydefaults_e=None,
ann_e={}, formatted=None):
- with self.assertWarns(DeprecationWarning):
- args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
- inspect.getfullargspec(routine)
+ args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
+ inspect.getfullargspec(routine)
self.assertEqual(args, args_e)
self.assertEqual(varargs, varargs_e)
self.assertEqual(varkw, varkw_e)
@@ -777,9 +774,8 @@ class TestClassesAndFunctions(unittest.TestCase):
self.assertEqual(kwonlydefaults, kwonlydefaults_e)
self.assertEqual(ann, ann_e)
if formatted is not None:
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults,
- kwonlyargs, kwonlydefaults, ann),
+ self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults,
+ kwonlyargs, kwonlydefaults, ann),
formatted)
def test_getargspec(self):
@@ -879,13 +875,11 @@ class TestClassesAndFunctions(unittest.TestCase):
def test_getfullargspec_signature_annos(self):
def test(a:'spam') -> 'ham': pass
- with self.assertWarns(DeprecationWarning):
- spec = inspect.getfullargspec(test)
+ spec = inspect.getfullargspec(test)
self.assertEqual(test.__annotations__, spec.annotations)
def test(): pass
- with self.assertWarns(DeprecationWarning):
- spec = inspect.getfullargspec(test)
+ spec = inspect.getfullargspec(test)
self.assertEqual(test.__annotations__, spec.annotations)
@unittest.skipIf(MISSING_C_DOCSTRINGS,
@@ -910,8 +904,7 @@ class TestClassesAndFunctions(unittest.TestCase):
def test_getfullargspec_builtin_func(self):
import _testcapi
builtin = _testcapi.docstring_with_signature_with_defaults
- with self.assertWarns(DeprecationWarning):
- spec = inspect.getfullargspec(builtin)
+ spec = inspect.getfullargspec(builtin)
self.assertEqual(spec.defaults[0], 'avocado')
@cpython_only
@@ -920,20 +913,17 @@ class TestClassesAndFunctions(unittest.TestCase):
def test_getfullargspec_builtin_func_no_signature(self):
import _testcapi
builtin = _testcapi.docstring_no_signature
- with self.assertWarns(DeprecationWarning):
- with self.assertRaises(TypeError):
- inspect.getfullargspec(builtin)
+ with self.assertRaises(TypeError):
+ inspect.getfullargspec(builtin)
def test_getfullargspec_definition_order_preserved_on_kwonly(self):
for fn in signatures_with_lexicographic_keyword_only_parameters():
- with self.assertWarns(DeprecationWarning):
- signature = inspect.getfullargspec(fn)
+ signature = inspect.getfullargspec(fn)
l = list(signature.kwonlyargs)
sorted_l = sorted(l)
self.assertTrue(l)
self.assertEqual(l, sorted_l)
- with self.assertWarns(DeprecationWarning):
- signature = inspect.getfullargspec(unsorted_keyword_only_parameters_fn)
+ signature = inspect.getfullargspec(unsorted_keyword_only_parameters_fn)
l = list(signature.kwonlyargs)
self.assertEqual(l, unsorted_keyword_only_parameters)
@@ -1390,9 +1380,8 @@ class TestGetcallargsFunctions(unittest.TestCase):
def assertEqualCallArgs(self, func, call_params_string, locs=None):
locs = dict(locs or {}, func=func)
r1 = eval('func(%s)' % call_params_string, None, locs)
- with self.assertWarns(DeprecationWarning):
- r2 = eval('inspect.getcallargs(func, %s)' % call_params_string, None,
- locs)
+ r2 = eval('inspect.getcallargs(func, %s)' % call_params_string, None,
+ locs)
self.assertEqual(r1, r2)
def assertEqualException(self, func, call_param_string, locs=None):
@@ -1404,9 +1393,8 @@ class TestGetcallargsFunctions(unittest.TestCase):
else:
self.fail('Exception not raised')
try:
- with self.assertWarns(DeprecationWarning):
- eval('inspect.getcallargs(func, %s)' % call_param_string, None,
- locs)
+ eval('inspect.getcallargs(func, %s)' % call_param_string, None,
+ locs)
except Exception as e:
ex2 = e
else:
@@ -1564,16 +1552,14 @@ class TestGetcallargsFunctions(unittest.TestCase):
def f5(*, a): pass
with self.assertRaisesRegex(TypeError,
'missing 1 required keyword-only'):
- with self.assertWarns(DeprecationWarning):
- inspect.getcallargs(f5)
+ inspect.getcallargs(f5)
# issue20817:
def f6(a, b, c):
pass
with self.assertRaisesRegex(TypeError, "'a', 'b' and 'c'"):
- with self.assertWarns(DeprecationWarning):
- inspect.getcallargs(f6)
+ inspect.getcallargs(f6)
# bpo-33197
with self.assertRaisesRegex(ValueError,
diff --git a/Misc/NEWS.d/3.8.0a4.rst b/Misc/NEWS.d/3.8.0a4.rst
index 76bb497..b92e60a 100644
--- a/Misc/NEWS.d/3.8.0a4.rst
+++ b/Misc/NEWS.d/3.8.0a4.rst
@@ -33,17 +33,6 @@ directory if the :envvar:`PATH` environment variable is not set.
..
-.. bpo: 36751
-.. date: 2019-04-29-23-30-21
-.. nonce: 3NCRbm
-.. section: Core and Builtins
-
-The :func:`~inspect.getfullargspec` function in the :mod:`inspect` module is
-deprecated in favor of the :func:`inspect.signature` API. Contributed by
-Pablo Galindo.
-
-..
-
.. bpo: 36722
.. date: 2019-04-25-21-02-40
.. nonce: 8NApVM