Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
aee19f54
Unverified
Kaydet (Commit)
aee19f54
authored
May 16, 2019
tarafından
Pablo Galindo
Kaydeden (comit)
GitHub
May 16, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36751: Undeprecate getfullargspec (GH-13245)
üst
54b43bb3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
60 deletions
+20
-60
inspect.rst
Doc/library/inspect.rst
+0
-5
3.8.rst
Doc/whatsnew/3.8.rst
+0
-4
inspect.py
Lib/inspect.py
+0
-6
test_inspect.py
Lib/test/test_inspect.py
+20
-34
3.8.0a4.rst
Misc/NEWS.d/3.8.0a4.rst
+0
-11
No files found.
Doc/library/inspect.rst
Dosyayı görüntüle @
aee19f54
...
...
@@ -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
...
...
Doc/whatsnew/3.8.rst
Dosyayı görüntüle @
aee19f54
...
...
@@ -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
========================
...
...
Lib/inspect.py
Dosyayı görüntüle @
aee19f54
...
...
@@ -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`
#
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
aee19f54
...
...
@@ -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
,
...
...
Misc/NEWS.d/3.8.0a4.rst
Dosyayı görüntüle @
aee19f54
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment