Skip to content

Commit 023532e

Browse files
authored
bpo-29684: Fix minor regression of PyEval_CallObjectWithKeywords. (GH-378)
1 parent 1b93ed4 commit 023532e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ What's New in Python 3.6.1 release candidate 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- bpo-29684: Fix minor regression of PyEval_CallObjectWithKeywords.
14+
It should raise TypeError when kwargs is not a dict. But it might
15+
cause segv when args=NULL and kwargs is not a dict.
16+
1317
- Issue #28598: Support __rmod__ for subclasses of str being called before
1418
str.__mod__. Patch by Martijn Pieters.
1519

Python/ceval.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4699,11 +4699,7 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
46994699
assert(!PyErr_Occurred());
47004700
#endif
47014701

4702-
if (args == NULL) {
4703-
return _PyObject_FastCallDict(func, NULL, 0, kwargs);
4704-
}
4705-
4706-
if (!PyTuple_Check(args)) {
4702+
if (args != NULL && !PyTuple_Check(args)) {
47074703
PyErr_SetString(PyExc_TypeError,
47084704
"argument list must be a tuple");
47094705
return NULL;
@@ -4715,7 +4711,12 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
47154711
return NULL;
47164712
}
47174713

4718-
return PyObject_Call(func, args, kwargs);
4714+
if (args == NULL) {
4715+
return _PyObject_FastCallDict(func, NULL, 0, kwargs);
4716+
}
4717+
else {
4718+
return PyObject_Call(func, args, kwargs);
4719+
}
47194720
}
47204721

47214722
const char *

0 commit comments

Comments
 (0)