summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-01-17 12:38:54 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-01-17 12:38:54 (GMT)
commitfc8d6f4b73c995b6de2e2b1058140192cf1f7e72 (patch)
tree497231809932ff9a24c549b6d103e02f73779a0b /Lib/test
parent1119a649167f8057f75b8fd26fa6cd2c1fc59a83 (diff)
downloadcpython-fc8d6f4b73c995b6de2e2b1058140192cf1f7e72.zip
cpython-fc8d6f4b73c995b6de2e2b1058140192cf1f7e72.tar.gz
cpython-fc8d6f4b73c995b6de2e2b1058140192cf1f7e72.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/test')
-rw-r--r--Lib/test/test_bytes.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index a4e5bd9..2813d96 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -817,6 +817,14 @@ 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''))
+ self.assertRaises((ValueError, OSError), os.mkdir, bytearray(b''))
+
+
class AssortedBytesTest(unittest.TestCase):
#
# Test various combinations of bytes and bytearray