mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #26822: itemgetter, attrgetter and methodcaller objects no longer
silently ignore keyword arguments.
This commit is contained in:
parent
95b5f0ad7e
commit
c2a2a751cf
3 changed files with 18 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue