summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-11-08 06:46:49 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-11-08 06:46:49 (GMT)
commita1e3422205333a15c8f90c09c0883cf5e5139145 (patch)
treeae9d3236f0482c6a1dd4000ff89459bd79155600 /Objects
parentcf1e760d3e91977f64336890d3dd0aa898b7fa25 (diff)
downloadcpython-a1e3422205333a15c8f90c09c0883cf5e5139145.zip
cpython-a1e3422205333a15c8f90c09c0883cf5e5139145.tar.gz
cpython-a1e3422205333a15c8f90c09c0883cf5e5139145.tar.bz2
Correctly forward exception in instance_contains().
Fixes #1591996. Patch contributed by Neal Norwitz.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/classobject.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 7680a3d..8560b68 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