Fix issue #1553: An errornous __length_hint__ can make list() raise a
SystemError.
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 43e8a3f..59674bf 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -760,8 +760,9 @@
/* Guess a result list size. */
n = _PyObject_LengthHint(b);
if (n < 0) {
- if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
- !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ if (PyErr_Occurred()
+ && !PyErr_ExceptionMatches(PyExc_TypeError)
+ && !PyErr_ExceptionMatches(PyExc_AttributeError)) {
Py_DECREF(it);
return NULL;
}