Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4c9dace

Browse files
committed
Fix bug reported by Tim Peters on python-dev:
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
1 parent 964c074 commit 4c9dace

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Python/ceval.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,18 +1970,17 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
19701970
*/
19711971
if (PyCFunction_Check(func)) {
19721972
int flags = PyCFunction_GET_FLAGS(func);
1973-
if (flags == METH_VARARGS) {
1973+
if (flags > 1 || nk != 0)
1974+
x = do_call(func, &stack_pointer,
1975+
na, nk);
1976+
else if (flags == METH_VARARGS) {
19741977
PyObject *callargs;
19751978
callargs = load_args(&stack_pointer, na);
19761979
x = call_cfunction(func, callargs, NULL);
19771980
Py_XDECREF(callargs);
1978-
} else if (flags == 0) {
1981+
} else if (flags == 0)
19791982
x = fast_cfunction(func,
19801983
&stack_pointer, na);
1981-
} else {
1982-
x = do_call(func, &stack_pointer,
1983-
na, nk);
1984-
}
19851984
} else {
19861985
if (PyMethod_Check(func)
19871986
&& PyMethod_GET_SELF(func) != NULL) {

0 commit comments

Comments
 (0)