diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-02-01 10:28:51 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-02-01 10:28:51 (GMT) |
commit | 211c6258294bf683935bff73a61ce3dd84070988 (patch) | |
tree | 8dc2a5a5fdcd1f7bc0e176bce006b12e1b588a05 /Objects/rangeobject.c | |
parent | 776e7014e97a79cc2bd5fffd15908e83ff0273cf (diff) | |
download | cpython-211c6258294bf683935bff73a61ce3dd84070988.zip cpython-211c6258294bf683935bff73a61ce3dd84070988.tar.gz cpython-211c6258294bf683935bff73a61ce3dd84070988.tar.bz2 |
Issue #1717, stage 2: remove uses of tp_compare in Modules and most
Objects.
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r-- | Objects/rangeobject.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index f9a9cc9..68f06a4 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -123,7 +123,7 @@ range_length_obj(rangeobject *r) Algorithm is equal to that of get_len_of_range(), but it operates on PyObjects (which are assumed to be PyLong or PyInt objects). ---------------------------------------------------------------*/ - int cmp_result, cmp_call; + int cmp_result; PyObject *lo, *hi; PyObject *step = NULL; PyObject *diff = NULL; @@ -134,13 +134,12 @@ range_length_obj(rangeobject *r) PyObject *zero = PyLong_FromLong(0); if (zero == NULL) return NULL; - cmp_call = PyObject_Cmp(r->step, zero, &cmp_result); + cmp_result = PyObject_RichCompareBool(r->step, zero, Py_GT); Py_DECREF(zero); - if (cmp_call == -1) + if (cmp_result == -1) return NULL; - assert(cmp_result != 0); - if (cmp_result > 0) { + if (cmp_result == 1) { lo = r->start; hi = r->stop; step = r->step; @@ -154,7 +153,7 @@ range_length_obj(rangeobject *r) } /* if (lo >= hi), return length of 0. */ - if (PyObject_Compare(lo, hi) >= 0) { + if (PyObject_RichCompareBool(lo, hi, Py_GE) == 1) { Py_XDECREF(step); return PyLong_FromLong(0); } |