Fix str.translate()

Issue #26464: Fix str.translate() when string is ASCII and first replacements
removes character, but next replacement uses a non-ASCII character or a string
longer than 1 character. Regression introduced in Python 3.5.0.
This commit is contained in:
Victor Stinner 2016-03-01 21:30:30 +01:00
parent bb0dbd583b
commit 6c9aa8f2bf
3 changed files with 12 additions and 3 deletions

View file

@ -347,6 +347,10 @@ class UnicodeTest(string_tests.CommonTest,
"[a]")
self.assertEqual("[\xe9]".translate(str.maketrans({'\xe9': None})),
"[]")
self.assertEqual('axb'.translate(str.maketrans({'a': None, 'b': '123'})),
"x123")
self.assertEqual('axb'.translate(str.maketrans({'a': None, 'b': '\xe9'})),
"x\xe9")
# invalid Unicode characters
invalid_char = 0x10ffff+1