Issue 1704621. Fix segfaults in list_repeat() and list_inplace_repeat().

The C changes aren't quite the same as the patch given there; the test is.
This commit is contained in:
Guido van Rossum 2007-11-12 20:04:41 +00:00
parent 50bbcc27e3
commit 809123c61f
2 changed files with 14 additions and 5 deletions

View file

@ -306,6 +306,13 @@ class CommonTest(unittest.TestCase):
self.assertEqual(self.type2test(s)*(-4), self.type2test([]))
self.assertEqual(id(s), id(s*1))
def test_bigrepeat(self):
x = self.type2test([0])
x *= 2**16
self.assertRaises(MemoryError, x.__mul__, 2**16)
if hasattr(x, '__imul__'):
self.assertRaises(MemoryError, x.__imul__, 2**16)
def test_subscript(self):
a = self.type2test([10, 11])
self.assertEqual(a.__getitem__(0L), 10)