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.
This commit is contained in:
Alexander Belopolsky 2010-08-16 18:55:46 +00:00
parent 27354ccec9
commit e29e6bffb5
4 changed files with 26 additions and 8 deletions

View file

@ -302,8 +302,9 @@ functools_reduce(PyObject *self, PyObject *args)
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;
}