Python -builtin constructors silently ignored keyword arguments.
Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments" exception is thrown if keyword arguments are used. Hence constructors and normal methods/functions behave in the same way. Closes issue #1595
This commit is contained in:
parent
e7d0533a6f
commit
67e8334ac8
6 changed files with 376 additions and 4 deletions
|
|
@ -183,6 +183,19 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
|
|||
}
|
||||
}
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) {
|
||||
int no_kwargs = 1;
|
||||
if (kwargs) {
|
||||
assert(PyDict_Check(kwargs));
|
||||
if (PyDict_Size(kwargs) > 0) {
|
||||
PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name);
|
||||
no_kwargs = 0;
|
||||
}
|
||||
}
|
||||
return no_kwargs;
|
||||
}
|
||||
|
||||
/* A functor is a function object with one single object argument */
|
||||
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue