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
c2a2a751
Kaydet (Commit)
c2a2a751
authored
Nis 23, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #26822: itemgetter, attrgetter and methodcaller objects no longer
silently ignore keyword arguments.
üst
95b5f0ad
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
test_operator.py
Lib/test/test_operator.py
+9
-0
NEWS
Misc/NEWS
+3
-0
_operator.c
Modules/_operator.c
+6
-0
No files found.
Lib/test/test_operator.py
Dosyayı görüntüle @
c2a2a751
...
...
@@ -318,6 +318,9 @@ class OperatorTestCase:
a
.
name
=
'arthur'
f
=
operator
.
attrgetter
(
'name'
)
self
.
assertEqual
(
f
(
a
),
'arthur'
)
self
.
assertRaises
(
TypeError
,
f
)
self
.
assertRaises
(
TypeError
,
f
,
a
,
'dent'
)
self
.
assertRaises
(
TypeError
,
f
,
a
,
surname
=
'dent'
)
f
=
operator
.
attrgetter
(
'rank'
)
self
.
assertRaises
(
AttributeError
,
f
,
a
)
self
.
assertRaises
(
TypeError
,
operator
.
attrgetter
,
2
)
...
...
@@ -365,6 +368,9 @@ class OperatorTestCase:
a
=
'ABCDE'
f
=
operator
.
itemgetter
(
2
)
self
.
assertEqual
(
f
(
a
),
'C'
)
self
.
assertRaises
(
TypeError
,
f
)
self
.
assertRaises
(
TypeError
,
f
,
a
,
3
)
self
.
assertRaises
(
TypeError
,
f
,
a
,
size
=
3
)
f
=
operator
.
itemgetter
(
10
)
self
.
assertRaises
(
IndexError
,
f
,
a
)
...
...
@@ -411,6 +417,9 @@ class OperatorTestCase:
self
.
assertRaises
(
IndexError
,
f
,
a
)
f
=
operator
.
methodcaller
(
'foo'
,
1
,
2
)
self
.
assertEqual
(
f
(
a
),
3
)
self
.
assertRaises
(
TypeError
,
f
)
self
.
assertRaises
(
TypeError
,
f
,
a
,
3
)
self
.
assertRaises
(
TypeError
,
f
,
a
,
spam
=
3
)
f
=
operator
.
methodcaller
(
'bar'
)
self
.
assertEqual
(
f
(
a
),
42
)
self
.
assertRaises
(
TypeError
,
f
,
a
,
a
)
...
...
Misc/NEWS
Dosyayı görüntüle @
c2a2a751
...
...
@@ -107,6 +107,9 @@ Core and Builtins
Library
-------
- Issue #26822: itemgetter, attrgetter and methodcaller objects no longer
silently ignore keyword arguments.
- Issue #26733: Disassembling a class now disassembles class and static methods.
Patch by Xiang Zhang.
...
...
Modules/_operator.c
Dosyayı görüntüle @
c2a2a751
...
...
@@ -460,6 +460,8 @@ itemgetter_call(itemgetterobject *ig, PyObject *args, PyObject *kw)
PyObject
*
obj
,
*
result
;
Py_ssize_t
i
,
nitems
=
ig
->
nitems
;
if
(
!
_PyArg_NoKeywords
(
"itemgetter"
,
kw
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"itemgetter"
,
1
,
1
,
&
obj
))
return
NULL
;
if
(
nitems
==
1
)
...
...
@@ -747,6 +749,8 @@ attrgetter_call(attrgetterobject *ag, PyObject *args, PyObject *kw)
PyObject
*
obj
,
*
result
;
Py_ssize_t
i
,
nattrs
=
ag
->
nattrs
;
if
(
!
_PyArg_NoKeywords
(
"attrgetter"
,
kw
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"attrgetter"
,
1
,
1
,
&
obj
))
return
NULL
;
if
(
ag
->
nattrs
==
1
)
/* ag->attr is always a tuple */
...
...
@@ -988,6 +992,8 @@ methodcaller_call(methodcallerobject *mc, PyObject *args, PyObject *kw)
{
PyObject
*
method
,
*
obj
,
*
result
;
if
(
!
_PyArg_NoKeywords
(
"methodcaller"
,
kw
))
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"methodcaller"
,
1
,
1
,
&
obj
))
return
NULL
;
method
=
PyObject_GetAttr
(
obj
,
mc
->
name
);
...
...
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