Skip to content

Commit 33a56b7

Browse files
committed
bpo-29684: Fix minor regression of PyEval_CallObjectWithKeywords
It should raise TypeError when kwargs is not a dict.
1 parent 43f5df5 commit 33a56b7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Objects/call.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -766,11 +766,7 @@ PyEval_CallObjectWithKeywords(PyObject *callable,
766766
assert(!PyErr_Occurred());
767767
#endif
768768

769-
if (args == NULL) {
770-
return _PyObject_FastCallDict(callable, NULL, 0, kwargs);
771-
}
772-
773-
if (!PyTuple_Check(args)) {
769+
if (args != NULL && !PyTuple_Check(args)) {
774770
PyErr_SetString(PyExc_TypeError,
775771
"argument list must be a tuple");
776772
return NULL;
@@ -782,7 +778,12 @@ PyEval_CallObjectWithKeywords(PyObject *callable,
782778
return NULL;
783779
}
784780

785-
return PyObject_Call(callable, args, kwargs);
781+
if (args == NULL) {
782+
return _PyObject_FastCallDict(callable, NULL, 0, kwargs);
783+
}
784+
else {
785+
return PyObject_Call(callable, args, kwargs);
786+
}
786787
}
787788

788789

0 commit comments

Comments
 (0)