summaryrefslogtreecommitdiffstats
path: root/Objects/descrobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-10-22 00:43:43 (GMT)
committerGuido van Rossum <guido@python.org>2001-10-22 00:43:43 (GMT)
commitc8e5645f15054a87945d5f62dc23c6e49a394db5 (patch)
tree94172c8b5b197c564ba64789b81cd41334b996a9 /Objects/descrobject.c
parentd6bebce5e5a6e92b6949dd001d3d467a7aa1aaef (diff)
downloadcpython-c8e5645f15054a87945d5f62dc23c6e49a394db5.zip
cpython-c8e5645f15054a87945d5f62dc23c6e49a394db5.tar.gz
cpython-c8e5645f15054a87945d5f62dc23c6e49a394db5.tar.bz2
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__.
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r--Objects/descrobject.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index e4d9f33..c5e793d 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -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);
}