diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-17 12:26:20 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-17 12:26:20 (GMT) |
commit | e80a6a4ead1da87d2a4149bfcbb95c1a3320dbc2 (patch) | |
tree | 8fd4b9d3e430610e4fea82bbc2974bca013d0c6a /Lib | |
parent | aee900338e76c9d0879bf9470bc3be7912b11817 (diff) | |
download | cpython-e80a6a4ead1da87d2a4149bfcbb95c1a3320dbc2.zip cpython-e80a6a4ead1da87d2a4149bfcbb95c1a3320dbc2.tar.gz cpython-e80a6a4ead1da87d2a4149bfcbb95c1a3320dbc2.tar.bz2 |
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.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_bytes.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index f2c9aa3..666894f 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -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 |