diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-05-21 10:43:34 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-05-21 10:43:34 (GMT) |
commit | 03b43d8a77f188f836262c201160a7ba9f2174bc (patch) | |
tree | 27d2e42a7b34460be505b79fb9dee0d381153ad7 /Objects/rangeobject.c | |
parent | c2f6a58ffd2c65da240a99e050eb4ffae1555a56 (diff) | |
download | cpython-03b43d8a77f188f836262c201160a7ba9f2174bc.zip cpython-03b43d8a77f188f836262c201160a7ba9f2174bc.tar.gz cpython-03b43d8a77f188f836262c201160a7ba9f2174bc.tar.bz2 |
repr(range(10)) now returns 'range(0, 10)' for clarity.
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r-- | Objects/rangeobject.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index ad5d2fb..4a45212 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -234,24 +234,17 @@ range_item(rangeobject *r, Py_ssize_t i) static PyObject * range_repr(rangeobject *r) { - Py_ssize_t istart, istep; + Py_ssize_t istep; /* Check for special case values for printing. We don't always - need the start or step values. We don't care about errors + need the step value. We don't care about errors (it means overflow), so clear the errors. */ - istart = PyNumber_AsSsize_t(r->start, NULL); - if (istart != 0 || (istart == -1 && PyErr_Occurred())) { - PyErr_Clear(); - } - istep = PyNumber_AsSsize_t(r->step, NULL); if (istep != 1 || (istep == -1 && PyErr_Occurred())) { PyErr_Clear(); } - if (istart == 0 && istep == 1) - return PyUnicode_FromFormat("range(%R)", r->stop); - else if (istep == 1) + if (istep == 1) return PyUnicode_FromFormat("range(%R, %R)", r->start, r->stop); else return PyUnicode_FromFormat("range(%R, %R, %R)", |