From 7e5343b882006ba4853f2b0b1064f6b1a458f790 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 20 Nov 2010 22:40:10 +0000 Subject: [PATCH] Add error handling in range_count. --- Objects/rangeobject.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 2188dfba597..d7bf018a1d4 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);