Mercurial > cpython-lru_cache-weakref
diff Objects/classobject.c @ 40302:78c75b3d3d0b 2.5
Correctly forward exception in instance_contains().
Fixes #1591996. Patch contributed by Neal Norwitz.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Wed, 08 Nov 2006 06:46:49 +0000 |
| parents | 52460b092b5a |
| children | 54179538a387 |
line wrap: on
line diff
--- a/Objects/classobject.c Tue Nov 07 20:39:58 2006 +0000 +++ b/Objects/classobject.c Wed Nov 08 06:46:49 2006 +0000 @@ -1318,15 +1318,17 @@ /* Couldn't find __contains__. */ if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + Py_ssize_t rc; /* Assume the failure was simply due to that there is no * __contains__ attribute, and try iterating instead. */ PyErr_Clear(); - return _PySequence_IterSearch((PyObject *)inst, member, - PY_ITERSEARCH_CONTAINS) > 0; + rc = _PySequence_IterSearch((PyObject *)inst, member, + PY_ITERSEARCH_CONTAINS); + if (rc >= 0) + return rc > 0; } - else - return -1; + return -1; } static PySequenceMethods
