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
76c6c593
Kaydet (Commit)
76c6c593
authored
Ock 29, 2014
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
inspect.signature: Add support for decorated (wrapped) builtins #20425
üst
b77511da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
inspect.py
Lib/inspect.py
+3
-3
test_inspect.py
Lib/test/test_inspect.py
+15
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
76c6c593
...
...
@@ -1530,9 +1530,6 @@ def signature(obj):
if
not
callable
(
obj
):
raise
TypeError
(
'{!r} is not a callable object'
.
format
(
obj
))
if
_signature_is_builtin
(
obj
):
return
Signature
.
from_builtin
(
obj
)
if
isinstance
(
obj
,
types
.
MethodType
):
# In this case we skip the first parameter of the underlying
# function (usually `self` or `cls`).
...
...
@@ -1570,6 +1567,9 @@ def signature(obj):
return
sig
.
replace
(
parameters
=
new_params
)
if
_signature_is_builtin
(
obj
):
return
Signature
.
from_builtin
(
obj
)
if
isinstance
(
obj
,
types
.
FunctionType
):
return
Signature
.
from_function
(
obj
)
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
76c6c593
...
...
@@ -1655,6 +1655,21 @@ class TestSignatureObject(unittest.TestCase):
__call__
=
type
test_callable
(
ThisWorksNow
())
@unittest.skipIf
(
MISSING_C_DOCSTRINGS
,
"Signature information for builtins requires docstrings"
)
def
test_signature_on_decorated_builtins
(
self
):
func
=
_testcapi
.
docstring_with_signature_with_defaults
def
decorator
(
func
):
@functools.wraps
(
func
)
def
wrapper
(
*
args
,
**
kwargs
)
->
int
:
return
func
(
*
args
,
**
kwargs
)
return
wrapper
decorated_func
=
decorator
(
func
)
self
.
assertEqual
(
inspect
.
signature
(
func
),
inspect
.
signature
(
decorated_func
))
def
test_signature_on_builtins_no_signature
(
self
):
with
self
.
assertRaisesRegex
(
ValueError
,
'no signature found for builtin'
):
...
...
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