aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-02 10:34:46 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-02 10:34:46 +0300
commit775a0ea0da81cd97e22541949a385bb34eb8184f (patch)
tree7f2ec826b06ccfa9c2caf3ef906efb698be45488 /Python/ceval.c
parent18c5e8e86f3ae2f67bbb893a5f89f9b4fb679f11 (diff)
parent7344285c1919e5ade8016a83a3ee02fd637a030d (diff)
downloadcpython-775a0ea0da81cd97e22541949a385bb34eb8184f.tar.gz
cpython-775a0ea0da81cd97e22541949a385bb34eb8184f.zip
Issue #28257: Improved error message when pass a non-iterable as
a var-positional argument. Added opcode BUILD_TUPLE_UNPACK_WITH_CALL.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index a09de05ebed..42f57db73e6 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2509,9 +2509,10 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
DISPATCH();
}
+ TARGET(BUILD_TUPLE_UNPACK_WITH_CALL)
TARGET(BUILD_TUPLE_UNPACK)
TARGET(BUILD_LIST_UNPACK) {
- int convert_to_tuple = opcode == BUILD_TUPLE_UNPACK;
+ int convert_to_tuple = opcode != BUILD_LIST_UNPACK;
Py_ssize_t i;
PyObject *sum = PyList_New(0);
PyObject *return_value;
@@ -2524,6 +2525,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
none_val = _PyList_Extend((PyListObject *)sum, PEEK(i));
if (none_val == NULL) {
+ if (opcode == BUILD_TUPLE_UNPACK_WITH_CALL &&
+ PyErr_ExceptionMatches(PyExc_TypeError)) {
+ PyObject *func = PEEK(1 + oparg);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s%.200s argument after * "
+ "must be an iterable, not %.200s",
+ PyEval_GetFuncName(func),
+ PyEval_GetFuncDesc(func),
+ PEEK(i)->ob_type->tp_name);
+ }
Py_DECREF(sum);
goto error;
}