Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.6] bpo-29684: Fix minor regression of PyEval_CallObjectWithKeywords. #378

Merged
merged 1 commit into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ What's New in Python 3.6.1 release candidate 1?
Core and Builtins
-----------------

- bpo-29684: Fix minor regression of PyEval_CallObjectWithKeywords.
It should raise TypeError when kwargs is not a dict. But it might
cause segv when args=NULL and kwargs is not a dict.

- Issue #28598: Support __rmod__ for subclasses of str being called before
str.__mod__. Patch by Martijn Pieters.

Expand Down
13 changes: 7 additions & 6 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4699,11 +4699,7 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
assert(!PyErr_Occurred());
#endif

if (args == NULL) {
return _PyObject_FastCallDict(func, NULL, 0, kwargs);
}

if (!PyTuple_Check(args)) {
if (args != NULL && !PyTuple_Check(args)) {
PyErr_SetString(PyExc_TypeError,
"argument list must be a tuple");
return NULL;
Expand All @@ -4715,7 +4711,12 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
return NULL;
}

return PyObject_Call(func, args, kwargs);
if (args == NULL) {
return _PyObject_FastCallDict(func, NULL, 0, kwargs);
}
else {
return PyObject_Call(func, args, kwargs);
}
}

const char *
Expand Down