diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-01 20:59:58 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-03-01 20:59:58 (GMT) |
commit | 337986740f26ade866dbe79e35188f72caa8fe8d (patch) | |
tree | 0dfe877dfcfe031ede9b96798c8f3645cb4a25e5 /Lib/test/test_unicode.py | |
parent | 6c9aa8f2bf46e28de74ce11d85bcd448c0d0d529 (diff) | |
download | cpython-337986740f26ade866dbe79e35188f72caa8fe8d.zip cpython-337986740f26ade866dbe79e35188f72caa8fe8d.tar.gz cpython-337986740f26ade866dbe79e35188f72caa8fe8d.tar.bz2 |
Issue #26464: Fix unicode_fast_translate() again
Initialize i variable if the string is non-ASCII.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r-- | Lib/test/test_unicode.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index b258db1..c30310e 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -341,16 +341,22 @@ class UnicodeTest(string_tests.CommonTest, "[XXX]") self.assertEqual("[a]".translate(str.maketrans({'a': '\xe9'})), "[\xe9]") + self.assertEqual('axb'.translate(str.maketrans({'a': None, 'b': '123'})), + "x123") + self.assertEqual('axb'.translate(str.maketrans({'a': None, 'b': '\xe9'})), + "x\xe9") + + # test non-ASCII (don't take the fast-path) self.assertEqual("[a]".translate(str.maketrans({'a': '<\xe9>'})), "[<\xe9>]") self.assertEqual("[\xe9]".translate(str.maketrans({'\xe9': 'a'})), "[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") + self.assertEqual("[\xe9]".translate(str.maketrans({'\xe9': '123'})), + "[123]") + self.assertEqual("[a\xe9]".translate(str.maketrans({'a': '<\u20ac>'})), + "[<\u20ac>\xe9]") # invalid Unicode characters invalid_char = 0x10ffff+1 |