]> granicus.if.org Git - python/commitdiff
Patch #1682205: a TypeError while unpacking an iterable is no longer
authorGeorg Brandl <georg@python.org>
Wed, 21 Mar 2007 09:00:55 +0000 (09:00 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 21 Mar 2007 09:00:55 +0000 (09:00 +0000)
masked by a generic one with the message "unpack non-sequence".
 (backport from rev. 54480)

Lib/test/test_unpack.py
Misc/NEWS
Python/ceval.c

index 3f726487e0a91bc6991ae579a80601f56f45639f..76a4822804804bee06ff35019fec3cec4d76d5a8 100644 (file)
@@ -55,7 +55,7 @@ Unpacking non-sequence
     >>> a, b, c = 7
     Traceback (most recent call last):
       ...
-    TypeError: unpack non-sequence
+    TypeError: 'int' object is not iterable
 
 Unpacking tuple of wrong size
 
index 2eea8b9d9f373af635840d1cea4b50dcdd465f12..d8c887100817d426c63619683e9ad8de6e32d237 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5.1c1?
 Core and builtins
 -----------------
 
+- Patch #1682205: a TypeError while unpacking an iterable is no longer
+  masked by a generic one with the message "unpack non-sequence".
+
 - Patch #1642547: Fix an error/crash when encountering syntax errors in
   complex if statements.
 
index 690b2be9b7ebcf2afb191ffec9c3ee5d626e1822..9dddd2ff2fb2bfc8f0daa920b227e910bb2e56d7 100644 (file)
@@ -1765,12 +1765,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                                        PUSH(w);
                                }
                        } else if (unpack_iterable(v, oparg,
-                                                stack_pointer + oparg))
+                                                stack_pointer + oparg)) {
                                stack_pointer += oparg;
-                       else {
-                               if (PyErr_ExceptionMatches(PyExc_TypeError))
-                                       PyErr_SetString(PyExc_TypeError,
-                                               "unpack non-sequence");
+                       } else {
+                               /* unpack_iterable() raised an exception */
                                why = WHY_EXCEPTION;
                        }
                        Py_DECREF(v);