diff options
author | Armin Rigo <arigo@tunes.org> | 2007-10-17 18:46:37 (GMT) |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2007-10-17 18:46:37 (GMT) |
commit | a1e42e11d51237a949ad2568f8a097d4b442fdec (patch) | |
tree | 09c46f959fa48a8a1bc29dd2839b79d80bab673a /Lib | |
parent | 7b201162cf842485b8b2de9b6989c6ce5ec02160 (diff) | |
download | cpython-a1e42e11d51237a949ad2568f8a097d4b442fdec.zip cpython-a1e42e11d51237a949ad2568f8a097d4b442fdec.tar.gz cpython-a1e42e11d51237a949ad2568f8a097d4b442fdec.tar.bz2 |
Fix the overflow checking of list_repeat.
Introduce overflow checking into list_inplace_repeat.
Backport candidate, possibly.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_list.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py index 711ac4b..3489529 100644 --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -1,4 +1,5 @@ import unittest +import sys from test import test_support, list_tests class ListTest(list_tests.CommonTest): @@ -18,6 +19,14 @@ class ListTest(list_tests.CommonTest): self.assertEqual(len([0]), 1) self.assertEqual(len([0, 1, 2]), 3) + def test_overflow(self): + lst = [4, 5, 6, 7] + n = int((sys.maxint*2+2) // len(lst)) + def mul(a, b): return a * b + def imul(a, b): a *= b + self.assertRaises((MemoryError, OverflowError), mul, lst, n) + self.assertRaises((MemoryError, OverflowError), imul, lst, n) + def test_main(verbose=None): test_support.run_unittest(ListTest) |