mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Issue #28257: Improved error message when pass a non-iterable as
a var-positional argument. Added opcode BUILD_TUPLE_UNPACK_WITH_CALL.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user