From 5e596769b025ce724e36aceeae52ce3c4c53c164 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 8 Oct 2013 21:07:46 +0300 Subject: [PATCH] Issue #18037: Do not escape '\u' and '\U' in raw strings. --- Lib/lib2to3/fixes/fix_unicode.py | 3 +-- Lib/lib2to3/tests/test_fixers.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/lib2to3/fixes/fix_unicode.py b/Lib/lib2to3/fixes/fix_unicode.py index 6555397da60..c7982c2b97c 100644 --- a/Lib/lib2to3/fixes/fix_unicode.py +++ b/Lib/lib2to3/fixes/fix_unicode.py @@ -28,8 +28,7 @@ class FixUnicode(fixer_base.BaseFix): return new elif node.type == token.STRING: val = node.value - if (not self.unicode_literals and val[0] in 'rR\'"' and - '\\' in val): + if not self.unicode_literals and val[0] in '\'"' and '\\' in val: val = r'\\'.join([ v.replace('\\u', r'\\u').replace('\\U', r'\\U') for v in val.split(r'\\') diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py index bffb741383c..2464446f40c 100644 --- a/Lib/lib2to3/tests/test_fixers.py +++ b/Lib/lib2to3/tests/test_fixers.py @@ -2830,7 +2830,7 @@ class Test_unicode(FixerTestCase): self.check(b, a) b = r"""r'\\\u20ac\U0001d121\\u20ac'""" - a = r"""r'\\\\u20ac\\U0001d121\\u20ac'""" + a = r"""r'\\\u20ac\U0001d121\\u20ac'""" self.check(b, a) def test_bytes_literal_escape_u(self):