Issue #6540: Fixed crash for bytearray.translate() with invalid parameters.
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 80e1b81..0555616 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1472,6 +1472,11 @@
self.assertEqual(bin(-(2**65)), '-0b1' + '0' * 65)
self.assertEqual(bin(-(2**65-1)), '-0b' + '1' * 65)
+ def test_bytearray_translate(self):
+ x = bytearray("abc")
+ self.assertRaises(ValueError, x.translate, "1", 1)
+ self.assertRaises(TypeError, x.translate, "1"*256, 1)
+
class TestSorted(unittest.TestCase):
def test_basic(self):