summaryrefslogtreecommitdiff
path: root/Objects/classobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-11-08 06:46:37 +0000
committerMartin v. Löwis <martin@v.loewis.de>2006-11-08 06:46:37 +0000
commit3a62404264e02acbee83994c411e292bccd4e8f2 (patch)
tree8e08132ecc808512f0c00ddbca7b08a1fe41afe3 /Objects/classobject.c
parente452f51bc4bf444c82e7465ea841f8058389c1f9 (diff)
downloadcpython-git-3a62404264e02acbee83994c411e292bccd4e8f2.tar.gz
Correctly forward exception in instance_contains().
Fixes #1591996. Patch contributed by Neal Norwitz. Will backport.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r--Objects/classobject.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 7680a3d6d0..8560b6842c 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -1318,15 +1318,17 @@ instance_contains(PyInstanceObject *inst, PyObject *member)
/* 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