]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix bug reported by Tim Peters on python-dev:
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 29 May 2001 16:23:26 +0000 (16:23 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 29 May 2001 16:23:26 +0000 (16:23 +0000)
Keyword arguments passed to builtin functions that don't take them are
ignored.

>>> {}.clear(x=2)
>>>

instead of

>>> {}.clear(x=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: clear() takes no keyword arguments

Python/ceval.c

index e407de49a953de45609d70c7b1190cdcdd7b2a96..902d52918bdecdacce352d63531afe22e7653b0a 100644 (file)
@@ -1970,18 +1970,17 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
                    */
                    if (PyCFunction_Check(func)) {
                            int flags = PyCFunction_GET_FLAGS(func);
-                           if (flags == METH_VARARGS) {
+                           if (flags > 1 || nk != 0) 
+                                   x = do_call(func, &stack_pointer,
+                                               na, nk);
+                           else if (flags == METH_VARARGS) {
                                    PyObject *callargs;
                                    callargs = load_args(&stack_pointer, na);
                                    x = call_cfunction(func, callargs, NULL);
                                    Py_XDECREF(callargs); 
-                           } else if (flags == 0) {
+                           } else if (flags == 0) 
                                    x = fast_cfunction(func,
                                                       &stack_pointer, na);
-                           } else {
-                                   x = do_call(func, &stack_pointer,
-                                               na, nk);
-                           }
                    } else {
                            if (PyMethod_Check(func)
                                && PyMethod_GET_SELF(func) != NULL) {