mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
#3071: tell how many values were expected when unpacking too many.
This commit is contained in:
parent
93eb42e805
commit
0310a83e7f
2 changed files with 5 additions and 4 deletions
|
@ -62,14 +62,14 @@ Unpacking tuple of wrong size
|
||||||
>>> a, b = t
|
>>> a, b = t
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
ValueError: too many values to unpack
|
ValueError: too many values to unpack (expected 2)
|
||||||
|
|
||||||
Unpacking tuple of wrong size
|
Unpacking tuple of wrong size
|
||||||
|
|
||||||
>>> a, b = l
|
>>> a, b = l
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
ValueError: too many values to unpack
|
ValueError: too many values to unpack (expected 2)
|
||||||
|
|
||||||
Unpacking sequence too short
|
Unpacking sequence too short
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ Unpacking sequence too long
|
||||||
>>> a, b = Seq()
|
>>> a, b = Seq()
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
ValueError: too many values to unpack
|
ValueError: too many values to unpack (expected 2)
|
||||||
|
|
||||||
Unpacking a sequence where the test for too long raises a different kind of
|
Unpacking a sequence where the test for too long raises a different kind of
|
||||||
error
|
error
|
||||||
|
|
|
@ -3464,7 +3464,8 @@ unpack_iterable(PyObject *v, int argcnt, int argcntafter, PyObject **sp)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Py_DECREF(w);
|
Py_DECREF(w);
|
||||||
PyErr_SetString(PyExc_ValueError, "too many values to unpack");
|
PyErr_Format(PyExc_ValueError, "too many values to unpack "
|
||||||
|
"(expected %d)", argcnt);
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue