diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-02 07:33:46 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-02 07:33:46 (GMT) |
commit | 7344285c1919e5ade8016a83a3ee02fd637a030d (patch) | |
tree | f5ac9aea45f055c175d1c462f63eb4fb341830b0 /Python/ceval.c | |
parent | 8f0f2056499847999fffa7af7a8872500a191203 (diff) | |
download | cpython-7344285c1919e5ade8016a83a3ee02fd637a030d.zip cpython-7344285c1919e5ade8016a83a3ee02fd637a030d.tar.gz cpython-7344285c1919e5ade8016a83a3ee02fd637a030d.tar.bz2 |
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.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 39cf330..717ac33 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; } |