diff options
author | Thomas Wouters <thomas@python.org> | 2006-04-04 17:28:12 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2006-04-04 17:28:12 (GMT) |
commit | f4d8f390536416c083c687206be8e2687e26c9a3 (patch) | |
tree | 4566f835f37272b4553cc60c8b393ac56ff0d13c /Objects/rangeobject.c | |
parent | 4aaaa49bacc59e4910fb929b7e6b641a1e66ca66 (diff) | |
download | cpython-f4d8f390536416c083c687206be8e2687e26c9a3.zip cpython-f4d8f390536416c083c687206be8e2687e26c9a3.tar.gz cpython-f4d8f390536416c083c687206be8e2687e26c9a3.tar.bz2 |
Make xrange more Py_ssize_t aware, by assuming a Py_ssize_t is always at
least as big as a long. I believe this to be a safe assumption that is being
made in many parts of CPython, but a check could be added.
len(xrange(sys.maxint)) works now, so fix the testsuite's odd exception for
64-bit platforms too. It also fixes 'zip(xrange(sys.maxint), it)' as a
portable-ish (if expensive) alternative to enumerate(it); since zip() now
calls len(), this was breaking on (real) 64-bit platforms. No additional
test was added for that behaviour.
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r-- | Objects/rangeobject.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 707ad46..e8374c1 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -104,13 +104,6 @@ range_item(rangeobject *r, Py_ssize_t i) static Py_ssize_t range_length(rangeobject *r) { -#if LONG_MAX != INT_MAX /* XXX ssize_t_max */ - if (r->len > INT_MAX) { - PyErr_SetString(PyExc_ValueError, - "xrange object size cannot be reported"); - return -1; - } -#endif return (Py_ssize_t)(r->len); } |