mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Methods of built-in types now properly check for keyword arguments
(formerly these were silently ignored). The only built-in methods that take keyword arguments are __call__, __init__ and __new__.
This commit is contained in:
parent
d6bebce5e5
commit
c8e5645f15
5 changed files with 45 additions and 12 deletions
|
|
@ -805,6 +805,17 @@ wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds)
|
|||
wrapperfunc wrapper = wp->descr->d_base->wrapper;
|
||||
PyObject *self = wp->self;
|
||||
|
||||
if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) {
|
||||
wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper;
|
||||
return (*wk)(self, args, wp->descr->d_wrapped, kwds);
|
||||
}
|
||||
|
||||
if (kwds != NULL && (!PyDict_Check(kwds) || PyDict_Size(kwds) != 0)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"wrapper %s doesn't take keyword arguments",
|
||||
wp->descr->d_base->name);
|
||||
return NULL;
|
||||
}
|
||||
return (*wrapper)(self, args, wp->descr->d_wrapped);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue