diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-17 12:31:10 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-17 12:31:10 (GMT) |
commit | bb667d433c9cf535dd2e574d039f4d905f53ff06 (patch) | |
tree | e9d5baf036e65d70473e6ddd21aad9691e699f0e /Lib | |
parent | 437053eee37cce76563941c5ff546a4f96620367 (diff) | |
download | cpython-bb667d433c9cf535dd2e574d039f4d905f53ff06.zip cpython-bb667d433c9cf535dd2e574d039f4d905f53ff06.tar.gz cpython-bb667d433c9cf535dd2e574d039f4d905f53ff06.tar.bz2 |
Merged revisions 77573 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77573 | antoine.pitrou | 2010-01-17 13:26:20 +0100 (dim., 17 janv. 2010) | 6 lines
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 48b0258..f8f36de 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -787,6 +787,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 |