summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-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 f2222a1..9ccc787 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -811,6 +811,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