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
bf304fcb
Kaydet (Commit)
bf304fcb
authored
May 30, 2015
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23934: Fix inspect.signature to fail correctly for builtin types.
Initial patch by James Powell.
üst
dce09c34
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
inspect.py
Lib/inspect.py
+5
-1
test_inspect.py
Lib/test/test_inspect.py
+6
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
bf304fcb
...
@@ -2255,9 +2255,13 @@ def _signature_from_callable(obj, *,
...
@@ -2255,9 +2255,13 @@ def _signature_from_callable(obj, *,
if
type
not
in
obj
.
__mro__
:
if
type
not
in
obj
.
__mro__
:
# We have a class (not metaclass), but no user-defined
# We have a class (not metaclass), but no user-defined
# __init__ or __new__ for it
# __init__ or __new__ for it
if
obj
.
__init__
is
object
.
__init__
:
if
(
obj
.
__init__
is
object
.
__init__
and
obj
.
__new__
is
object
.
__new__
):
# Return a signature of 'object' builtin.
# Return a signature of 'object' builtin.
return
signature
(
object
)
return
signature
(
object
)
else
:
raise
ValueError
(
'no signature found for builtin type {!r}'
.
format
(
obj
))
elif
not
isinstance
(
obj
,
_NonUserDefinedCallables
):
elif
not
isinstance
(
obj
,
_NonUserDefinedCallables
):
# An object with __call__
# An object with __call__
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
bf304fcb
...
@@ -1980,9 +1980,14 @@ class TestSignatureObject(unittest.TestCase):
...
@@ -1980,9 +1980,14 @@ class TestSignatureObject(unittest.TestCase):
@cpython_only
@cpython_only
def
test_signature_on_builtins_no_signature
(
self
):
def
test_signature_on_builtins_no_signature
(
self
):
import
_testcapi
import
_testcapi
with
self
.
assertRaisesRegex
(
ValueError
,
'no signature found for builtin'
):
with
self
.
assertRaisesRegex
(
ValueError
,
'no signature found for builtin'
):
inspect
.
signature
(
_testcapi
.
docstring_no_signature
)
inspect
.
signature
(
_testcapi
.
docstring_no_signature
)
with
self
.
assertRaisesRegex
(
ValueError
,
'no signature found for builtin'
):
inspect
.
signature
(
str
)
def
test_signature_on_non_function
(
self
):
def
test_signature_on_non_function
(
self
):
with
self
.
assertRaisesRegex
(
TypeError
,
'is not a callable object'
):
with
self
.
assertRaisesRegex
(
TypeError
,
'is not a callable object'
):
inspect
.
signature
(
42
)
inspect
.
signature
(
42
)
...
...
Misc/NEWS
Dosyayı görüntüle @
bf304fcb
...
@@ -31,6 +31,9 @@ Library
...
@@ -31,6 +31,9 @@ Library
- Issue #16991: Add a C implementation of OrderedDict.
- Issue #16991: Add a C implementation of OrderedDict.
- Issue #23934: Fix inspect.signature to fail correctly for builtin types
lacking signature information. Initial patch by James Powell.
What'
s
New
in
Python
3.5.0
beta
1
?
What'
s
New
in
Python
3.5.0
beta
1
?
==================================
==================================
...
...
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