summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-07 20:32:41 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-07 20:32:41 (GMT)
commit5665301baea21200771829516fc8edeec3b059b9 (patch)
treea80f7bd6be6a0db82c95ae2e90c56b6d419062d9 /Python
parentde0574bdabc1183706406b421dea2e3e3c165eb3 (diff)
downloadcpython-5665301baea21200771829516fc8edeec3b059b9.zip
cpython-5665301baea21200771829516fc8edeec3b059b9.tar.gz
cpython-5665301baea21200771829516fc8edeec3b059b9.tar.bz2
Issue #28257: Improved error message when pass a non-mapping as a var-keyword
argument.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 9f1af78..e9d0cbb 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2663,7 +2663,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
PyObject *intersection = _PyDictView_Intersect(sum, arg);
if (intersection == NULL) {
- if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ if (PyErr_ExceptionMatches(PyExc_AttributeError) ||
+ !PyMapping_Check(arg)) {
int function_location = (oparg>>8) & 0xff;
PyObject *func = (
PEEK(function_location + num_maps));
@@ -2707,9 +2708,21 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
if (PyDict_Update(sum, arg) < 0) {
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_TypeError,
- "'%.200s' object is not a mapping",
- arg->ob_type->tp_name);
+ if (with_call) {
+ int function_location = (oparg>>8) & 0xff;
+ PyObject *func = PEEK(function_location + num_maps);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s%.200s argument after ** "
+ "must be a mapping, not %.200s",
+ PyEval_GetFuncName(func),
+ PyEval_GetFuncDesc(func),
+ arg->ob_type->tp_name);
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "'%.200s' object is not a mapping",
+ arg->ob_type->tp_name);
+ }
}
Py_DECREF(sum);
goto error;