mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
Issue #9530: Fix undefined-behaviour-inducing overflow checks in bytes and bytearray implementations.
This commit is contained in:
parent
331ea92ade
commit
cf940c701f
3 changed files with 49 additions and 68 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue