From 33a56b74e11d9a0ec18e6e6ebe051e2e6812015b Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Tue, 14 Feb 2017 13:15:50 +0900 Subject: [PATCH 1/2] bpo-29684: Fix minor regression of PyEval_CallObjectWithKeywords It should raise TypeError when kwargs is not a dict. --- Objects/call.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Objects/call.c b/Objects/call.c index 310b4a205f3847..a4af816e30994e 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -766,11 +766,7 @@ PyEval_CallObjectWithKeywords(PyObject *callable, assert(!PyErr_Occurred()); #endif - if (args == NULL) { - return _PyObject_FastCallDict(callable, 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; @@ -782,7 +778,12 @@ PyEval_CallObjectWithKeywords(PyObject *callable, return NULL; } - return PyObject_Call(callable, args, kwargs); + if (args == NULL) { + return _PyObject_FastCallDict(callable, NULL, 0, kwargs); + } + else { + return PyObject_Call(callable, args, kwargs); + } } From c588f9ae1f475090047d785123bcb9da5024a859 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Wed, 1 Mar 2017 20:10:07 +0900 Subject: [PATCH 2/2] add NEWS entry --- Misc/NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 4f19e75aeaa8fc..6af660115fc3e6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ What's New in Python 3.7.0 alpha 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. + - bpo-28598: Support __rmod__ for subclasses of str being called before str.__mod__. Patch by Martijn Pieters.