]> granicus.if.org Git - python/commitdiff
Issue #18037: Do not escape '\u' and '\U' in raw strings.
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 8 Oct 2013 18:07:46 +0000 (21:07 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 8 Oct 2013 18:07:46 +0000 (21:07 +0300)
Lib/lib2to3/fixes/fix_unicode.py
Lib/lib2to3/tests/test_fixers.py

index 6555397da603811f8f3f6870cd72a08778b61012..c7982c2b97c3e1cacf5812a9ddd9d20fdda66496 100644 (file)
@@ -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'\\')
index bffb741383c44e65fe38d6b947ec7d4385a035ba..2464446f40cb2f694fbe71c45f20139d96f589b0 100644 (file)
@@ -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):