mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
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:
parent
bb0dbd583b
commit
6c9aa8f2bf
3 changed files with 12 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue