mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Issue #7561: Operations on empty bytearrays (such as int(bytearray())
)
could crash in many places because of the PyByteArray_AS_STRING() macro returning NULL. The macro now returns a statically allocated empty string instead.
This commit is contained in:
parent
aee900338e
commit
e80a6a4ead
4 changed files with 23 additions and 18 deletions
|
@ -783,6 +783,13 @@ class ByteArrayTest(BaseBytesTest):
|
|||
self.assertRaises(BufferError, delslice)
|
||||
self.assertEquals(b, orig)
|
||||
|
||||
def test_empty_bytearray(self):
|
||||
# Issue #7561: operations on empty bytearrays could crash in many
|
||||
# situations, due to a fragile implementation of the
|
||||
# PyByteArray_AS_STRING() C macro.
|
||||
self.assertRaises(ValueError, int, bytearray(b''))
|
||||
|
||||
|
||||
class AssortedBytesTest(unittest.TestCase):
|
||||
#
|
||||
# Test various combinations of bytes and bytearray
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue