diff Modules/_functoolsmodule.c @ 64068:715c44b60ef3

Issue #665761: functools.reduce() will no longer mask exceptions other than TypeError raised by the iterator argument. Also added a test to check that zip() already behaves similarly.
author Alexander Belopolsky <alexander.belopolsky@gmail.com>
date Mon, 16 Aug 2010 18:55:46 +0000
parents cab14be0ada1
children bf94b6a73fc8 2baad8bd0b4f
line wrap: on
line diff
--- a/Modules/_functoolsmodule.c	Mon Aug 16 18:41:19 2010 +0000
+++ b/Modules/_functoolsmodule.c	Mon Aug 16 18:55:46 2010 +0000
@@ -302,8 +302,9 @@
 
     it = PyObject_GetIter(seq);
     if (it == NULL) {
-        PyErr_SetString(PyExc_TypeError,
-            "reduce() arg 2 must support iteration");
+        if (PyErr_ExceptionMatches(PyExc_TypeError))
+            PyErr_SetString(PyExc_TypeError,
+                            "reduce() arg 2 must support iteration");
         Py_XDECREF(result);
         return NULL;
     }