summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-11-20 22:40:10 (GMT)
committerGeorg Brandl <georg@python.org>2010-11-20 22:40:10 (GMT)
commit7e5343b882006ba4853f2b0b1064f6b1a458f790 (patch)
treebe18e66403bf0444c366ba46c81b3763744cee70
parent0b458d52f9c58f0a47ea448e2349704fd33a7fe3 (diff)
downloadcpython-7e5343b882006ba4853f2b0b1064f6b1a458f790.zip
cpython-7e5343b882006ba4853f2b0b1064f6b1a458f790.tar.gz
cpython-7e5343b882006ba4853f2b0b1064f6b1a458f790.tar.bz2
Add error handling in range_count.
-rw-r--r--Objects/rangeobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 2188dfb..d7bf018 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -337,7 +337,10 @@ static PyObject *
range_count(rangeobject *r, PyObject *ob)
{
if (PyLong_CheckExact(ob) || PyBool_Check(ob)) {
- if (range_contains_long(r, ob))
+ int result = range_contains_long(r, ob);
+ if (result == -1)
+ return NULL;
+ else if (result)
return PyLong_FromLong(1);
else
return PyLong_FromLong(0);