From fa494fd88384acc52cf9292d0c89e2961c8f747f Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 30 May 2015 17:45:22 +0300 Subject: Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(), PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains() to check for and handle errors correctly. --- Objects/rangeobject.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Objects/rangeobject.c') diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index ca66a45d5f..c4ba715018 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); } -- cgit v1.2.1