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
72f389fe
Kaydet (Commit)
72f389fe
authored
May 28, 2015
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue 24298: Fix signature() to properly unwrap wrappers around bound methods
üst
fa0e7f67
507cd3cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
inspect.py
Lib/inspect.py
+9
-0
test_inspect.py
Lib/test/test_inspect.py
+13
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
72f389fe
...
...
@@ -2130,6 +2130,15 @@ def _signature_from_callable(obj, *,
# Was this function wrapped by a decorator?
if
follow_wrapper_chains
:
obj
=
unwrap
(
obj
,
stop
=
(
lambda
f
:
hasattr
(
f
,
"__signature__"
)))
if
isinstance
(
obj
,
types
.
MethodType
):
# If the unwrapped object is a *method*, we might want to
# skip its first parameter (self).
# See test_signature_wrapped_bound_method for details.
return
_signature_from_callable
(
obj
,
follow_wrapper_chains
=
follow_wrapper_chains
,
skip_bound_arg
=
skip_bound_arg
,
sigcls
=
sigcls
)
try
:
sig
=
obj
.
__signature__
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
72f389fe
...
...
@@ -2086,6 +2086,19 @@ class TestSignatureObject(unittest.TestCase):
with
self
.
assertRaisesRegex
(
ValueError
,
'invalid method signature'
):
self
.
signature
(
Test
())
def
test_signature_wrapped_bound_method
(
self
):
# Issue 24298
class
Test
:
def
m1
(
self
,
arg1
,
arg2
=
1
)
->
int
:
pass
@functools.wraps
(
Test
()
.
m1
)
def
m1d
(
*
args
,
**
kwargs
):
pass
self
.
assertEqual
(
self
.
signature
(
m1d
),
(((
'arg1'
,
...
,
...
,
"positional_or_keyword"
),
(
'arg2'
,
1
,
...
,
"positional_or_keyword"
)),
int
))
def
test_signature_on_classmethod
(
self
):
class
Test
:
@classmethod
...
...
Misc/NEWS
Dosyayı görüntüle @
72f389fe
...
...
@@ -263,6 +263,9 @@ Library
-
Issue
#
23898
:
Fix
inspect
.
classify_class_attrs
()
to
support
attributes
with
overloaded
__eq__
and
__bool__
.
Patch
by
Mike
Bayer
.
-
Issue
#
24298
:
Fix
inspect
.
signature
()
to
correctly
unwrap
wrappers
around
bound
methods
.
IDLE
----
...
...
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