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
bd41d1b1
Kaydet (Commit)
bd41d1b1
authored
Ock 29, 2013
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17071: Signature.bind() now works when one of the keyword arguments is named ``self``.
üst
c5b75db5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
inspect.py
Lib/inspect.py
+4
-4
test_inspect.py
Lib/test/test_inspect.py
+10
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
bd41d1b1
...
...
@@ -2028,19 +2028,19 @@ class Signature:
return
self
.
_bound_arguments_cls
(
self
,
arguments
)
def
bind
(
self
,
*
args
,
**
kwargs
):
def
bind
(
__bind_
self
,
*
args
,
**
kwargs
):
'''Get a BoundArguments object, that maps the passed `args`
and `kwargs` to the function's signature. Raises `TypeError`
if the passed arguments can not be bound.
'''
return
self
.
_bind
(
args
,
kwargs
)
return
__bind_
self
.
_bind
(
args
,
kwargs
)
def
bind_partial
(
self
,
*
args
,
**
kwargs
):
def
bind_partial
(
__bind_
self
,
*
args
,
**
kwargs
):
'''Get a BoundArguments object, that partially maps the
passed `args` and `kwargs` to the function's signature.
Raises `TypeError` if the passed arguments can not be bound.
'''
return
self
.
_bind
(
args
,
kwargs
,
partial
=
True
)
return
__bind_
self
.
_bind
(
args
,
kwargs
,
partial
=
True
)
def
__str__
(
self
):
result
=
[]
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
bd41d1b1
...
...
@@ -2241,6 +2241,16 @@ class TestSignatureBind(unittest.TestCase):
with
self
.
assertRaisesRegex
(
TypeError
,
"parameter is positional only"
):
self
.
call
(
test
,
a_po
=
1
,
b_po
=
2
)
def
test_signature_bind_with_self_arg
(
self
):
# Issue #17071: one of the parameters is named "self
def
test
(
a
,
self
,
b
):
pass
sig
=
inspect
.
signature
(
test
)
ba
=
sig
.
bind
(
1
,
2
,
3
)
self
.
assertEqual
(
ba
.
args
,
(
1
,
2
,
3
))
ba
=
sig
.
bind
(
1
,
self
=
2
,
b
=
3
)
self
.
assertEqual
(
ba
.
args
,
(
1
,
2
,
3
))
class
TestBoundArguments
(
unittest
.
TestCase
):
def
test_signature_bound_arguments_unhashable
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
bd41d1b1
...
...
@@ -164,6 +164,9 @@ Core and Builtins
Library
-------
- Issue #17071: Signature.bind() now works when one of the keyword arguments
is named ``self``.
- Issue #12004: Fix an internal error in PyZipFile when writing an invalid
Python file. Patch by Ben Morgan.
...
...
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