[Python-checkins] cpython (merge 3.3 -> default): Issue #18037: Do not escape '\u' and '\U' in raw strings.

serhiy.storchaka python-checkins at python.org
Tue Oct 8 20:09:31 CEST 2013


http://hg.python.org/cpython/rev/a49d313a28ae
changeset:   86147:a49d313a28ae
parent:      86144:0f6133498def
parent:      86146:acb2dacd0d24
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Oct 08 21:08:48 2013 +0300
summary:
  Issue #18037: Do not escape '\u' and '\U' in raw strings.

files:
  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
--- a/Lib/lib2to3/fixes/fix_unicode.py
+++ b/Lib/lib2to3/fixes/fix_unicode.py
@@ -28,8 +28,7 @@
             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
--- a/Lib/lib2to3/tests/test_fixers.py
+++ b/Lib/lib2to3/tests/test_fixers.py
@@ -2889,7 +2889,7 @@
         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):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list