summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-04-04 17:28:12 (GMT)
committerThomas Wouters <thomas@python.org>2006-04-04 17:28:12 (GMT)
commitf4d8f390536416c083c687206be8e2687e26c9a3 (patch)
tree4566f835f37272b4553cc60c8b393ac56ff0d13c /Lib
parent4aaaa49bacc59e4910fb929b7e6b641a1e66ca66 (diff)
downloadcpython-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 'Lib')
-rw-r--r--Lib/test/test_xrange.py7
1 files changed, 1 insertions, 6 deletions
diff --git a/Lib/test/test_xrange.py b/Lib/test/test_xrange.py
index 9f9daa7..eafb7fa 100644
--- a/Lib/test/test_xrange.py
+++ b/Lib/test/test_xrange.py
@@ -54,12 +54,7 @@ class XrangeTest(unittest.TestCase):
self.assertRaises(OverflowError, xrange, 0, 2*sys.maxint)
r = xrange(-sys.maxint, sys.maxint, 2)
- if sys.maxint > 0x7fffffff:
- # XXX raising ValueError is less than ideal, but this can't
- # be fixed until range_length() returns a long in rangeobject.c
- self.assertRaises(ValueError, len, r)
- else:
- self.assertEqual(len(r), sys.maxint)
+ self.assertEqual(len(r), sys.maxint)
self.assertRaises(OverflowError, xrange, -sys.maxint-1, sys.maxint, 2)
def test_main():