Merging change 55102 from the trunk:

Fix those parts in the testsuite that assumed that sys.maxint would cause overflow on x64.  Now the testsuite is well behaved on that platform.
This commit is contained in:
Kristján Valur Jónsson 2007-05-07 13:33:39 +00:00
parent 4e6b5e9ead
commit 7bca027f64
4 changed files with 17 additions and 10 deletions

View file

@ -1,7 +1,10 @@
import unittest
from test import test_support
import operator
import sys
from sys import maxint
maxsize = test_support.MAX_Py_ssize_t
minsize = -maxsize-1
class oldstyle:
def __index__(self):
@ -185,7 +188,7 @@ class OverflowTestCase(unittest.TestCase):
def _getitem_helper(self, base):
class GetItem(base):
def __len__(self):
return maxint
return maxint #cannot return long here
def __getitem__(self, key):
return key
def __getslice__(self, i, j):
@ -193,8 +196,8 @@ class OverflowTestCase(unittest.TestCase):
x = GetItem()
self.assertEqual(x[self.pos], self.pos)
self.assertEqual(x[self.neg], self.neg)
self.assertEqual(x[self.neg:self.pos], (-1, maxint))
self.assertEqual(x[self.neg:self.pos:1].indices(maxint), (0, maxint, 1))
self.assertEqual(x[self.neg:self.pos], (maxint+minsize, maxsize))
self.assertEqual(x[self.neg:self.pos:1].indices(maxsize), (0, maxsize, 1))
def test_getitem(self):
self._getitem_helper(object)