From: Georg Brandl Date: Sat, 10 Jul 2010 10:32:36 +0000 (+0000) Subject: #3071: tell how many values were expected when unpacking too many. X-Git-Tag: v3.2a1~246 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0310a83e7f2cb7cdb94d5a1a737681119783c834;p=python #3071: tell how many values were expected when unpacking too many. --- diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py index b1531f306d..b1c483d4d5 100644 --- a/Lib/test/test_unpack.py +++ b/Lib/test/test_unpack.py @@ -62,14 +62,14 @@ Unpacking tuple of wrong size >>> a, b = t Traceback (most recent call last): ... - ValueError: too many values to unpack + ValueError: too many values to unpack (expected 2) Unpacking tuple of wrong size >>> a, b = l Traceback (most recent call last): ... - ValueError: too many values to unpack + ValueError: too many values to unpack (expected 2) Unpacking sequence too short @@ -83,7 +83,7 @@ Unpacking sequence too long >>> a, b = Seq() 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 error diff --git a/Python/ceval.c b/Python/ceval.c index 6e4911ae92..2d4b16a39a 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3464,7 +3464,8 @@ unpack_iterable(PyObject *v, int argcnt, int argcntafter, PyObject **sp) return 1; } 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; }