diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-06-24 18:36:46 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-06-24 18:36:46 (GMT) |
commit | eb36d31bb8d0fdf4be14fd14deaf88149e771417 (patch) | |
tree | aaa34d5cfebafef2da73e7c93652ca5a04676a11 /Objects | |
parent | eeb575f3290802bb542ad5f7442822586c8c08cf (diff) | |
download | cpython-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.c | 11 |
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; |