diff options
| author | Georg Brandl <georg@python.org> | 2008-12-28 11:55:24 (GMT) |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2008-12-28 11:55:24 (GMT) |
| commit | ef29f8634ca5415fda7aa75c9c142d3eaf2edebc (patch) | |
| tree | 83747d92acba51003a7598774a1a71c81408803a /Lib/test | |
| parent | 828a7066f12e758c30829363c8ec9018c6c2a94f (diff) | |
| download | cpython-ef29f8634ca5415fda7aa75c9c142d3eaf2edebc.zip cpython-ef29f8634ca5415fda7aa75c9c142d3eaf2edebc.tar.gz cpython-ef29f8634ca5415fda7aa75c9c142d3eaf2edebc.tar.bz2 | |
Backport r67975: #4759: fix segfault in bytearray.translate(x, None).
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_bytes.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 36defb8..00aee02 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -872,11 +872,19 @@ class AssortedBytesTest(unittest.TestCase): def test_translate(self): b = b'hello' + ba = bytearray(b) rosetta = bytearray(range(0, 256)) rosetta[ord('o')] = ord('e') c = b.translate(rosetta, b'l') self.assertEqual(b, b'hello') self.assertEqual(c, b'hee') + c = ba.translate(rosetta, b'l') + self.assertEqual(ba, b'hello') + self.assertEqual(c, b'hee') + c = b.translate(None, b'e') + self.assertEqual(c, b'hllo') + self.assertRaises(TypeError, b.translate, b'a'*256, None) + self.assertRaises(TypeError, ba.translate, b'a'*256, None) def test_split_bytearray(self): self.assertEqual(b'a b'.split(memoryview(b' ')), [b'a', b'b']) |
