From cf940c701f982d7a38144b31d09dc9613af841b7 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Tue, 10 Aug 2010 18:35:01 +0000 Subject: Issue #9530: Fix undefined-behaviour-inducing overflow checks in bytes and bytearray implementations. --- Lib/test/test_bytes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Lib/test/test_bytes.py') diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 16203a59f8..6a402b1ff9 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -220,8 +220,10 @@ class BaseBytesTest(unittest.TestCase): self.assertRaises(TypeError, lambda: b * 3.14) self.assertRaises(TypeError, lambda: 3.14 * b) # XXX Shouldn't bytes and bytearray agree on what to raise? - self.assertRaises((OverflowError, MemoryError), - lambda: b * sys.maxsize) + with self.assertRaises((OverflowError, MemoryError)): + c = b * sys.maxsize + with self.assertRaises((OverflowError, MemoryError)): + b *= sys.maxsize def test_repeat_1char(self): self.assertEqual(self.type2test(b'x')*100, self.type2test([ord('x')]*100)) -- cgit v1.2.1