mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
Issue #21118: Add unit test for invalid character replacement (code point higher than U+10ffff)
This commit is contained in:
parent
89a76abf20
commit
4ff33af257
2 changed files with 18 additions and 10 deletions
|
|
@ -280,6 +280,14 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertEqual("[\xe9]".translate(str.maketrans({'\xe9': None})),
|
||||
"[]")
|
||||
|
||||
# invalid Unicode characters
|
||||
invalid_char = 0x10ffff+1
|
||||
for before in "a\xe9\u20ac\U0010ffff":
|
||||
mapping = str.maketrans({before: invalid_char})
|
||||
text = "[%s]" % before
|
||||
self.assertRaises(ValueError, text.translate, mapping)
|
||||
|
||||
# errors
|
||||
self.assertRaises(TypeError, self.type2test.maketrans)
|
||||
self.assertRaises(ValueError, self.type2test.maketrans, 'abc', 'defg')
|
||||
self.assertRaises(TypeError, self.type2test.maketrans, 2, 'def')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue