summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-06-24 18:36:46 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-06-24 18:36:46 (GMT)
commiteb36d31bb8d0fdf4be14fd14deaf88149e771417 (patch)
treeaaa34d5cfebafef2da73e7c93652ca5a04676a11 /Objects
parenteeb575f3290802bb542ad5f7442822586c8c08cf (diff)
downloadcpython-eb36d31bb8d0fdf4be14fd14deaf88149e771417.zip
cpython-eb36d31bb8d0fdf4be14fd14deaf88149e771417.tar.gz
cpython-eb36d31bb8d0fdf4be14fd14deaf88149e771417.tar.bz2
Issue #6334: Fix buggy internal length calculation in builtin range function
Diffstat (limited to 'Objects')
-rw-r--r--Objects/rangeobject.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index f8174ca..11fd32e 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -581,7 +581,6 @@ range_iter(PyObject *seq)
{
rangeobject *r = (rangeobject *)seq;
longrangeiterobject *it;
- PyObject *tmp, *len;
long lstart, lstop, lstep;
assert(PyRange_Check(seq));
@@ -612,15 +611,9 @@ range_iter(PyObject *seq)
it->len = it->index = NULL;
- /* Calculate length: (r->stop - r->start) / r->step */
- tmp = PyNumber_Subtract(r->stop, r->start);
- if (!tmp)
+ it->len = range_length_obj(r);
+ if (!it->len)
goto create_failure;
- len = PyNumber_FloorDivide(tmp, r->step);
- Py_DECREF(tmp);
- if (!len)
- goto create_failure;
- it->len = len;
it->index = PyLong_FromLong(0);
if (!it->index)
goto create_failure;