Add error handling in range_count.
authorGeorg Brandl <georg@python.org>
Sat, 20 Nov 2010 22:40:10 +0000 (22:40 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 20 Nov 2010 22:40:10 +0000 (22:40 +0000)
Objects/rangeobject.c

index 2188dfba5974c44fbbcabffbb7eeead157206683..d7bf018a1d40be0b98379041158e7b4e7be9accf 100644 (file)
@@ -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);