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:
Guido van Rossum 2001-10-22 00:43:43 +00:00
parent d6bebce5e5
commit c8e5645f15
5 changed files with 45 additions and 12 deletions

View file

@ -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);
}