diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-08-10 18:35:01 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-08-10 18:35:01 (GMT) |
commit | cf940c701f982d7a38144b31d09dc9613af841b7 (patch) | |
tree | eb5368b6c9ab6fdf766c69fac3866a48c9c8a5cc /Lib/test | |
parent | 331ea92ade37e5dcf14c44df59e5eda2136b1a8f (diff) | |
download | cpython-cf940c701f982d7a38144b31d09dc9613af841b7.zip cpython-cf940c701f982d7a38144b31d09dc9613af841b7.tar.gz cpython-cf940c701f982d7a38144b31d09dc9613af841b7.tar.bz2 |
Issue #9530: Fix undefined-behaviour-inducing overflow checks in bytes and bytearray implementations.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_bytes.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 16203a5..6a402b1 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)) |