summaryrefslogtreecommitdiffstats
path: root/Objects/rangeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r--Objects/rangeobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 17fef42..da1d703 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -194,8 +194,11 @@ compute_range_length(PyObject *start, PyObject *stop, PyObject *step)
}
/* if (lo >= hi), return length of 0. */
- if (PyObject_RichCompareBool(lo, hi, Py_GE) == 1) {
+ cmp_result = PyObject_RichCompareBool(lo, hi, Py_GE);
+ if (cmp_result != 0) {
Py_XDECREF(step);
+ if (cmp_result < 0)
+ return NULL;
return PyLong_FromLong(0);
}