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

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


http://hg.python.org/cpython/rev/c498d1090970
changeset:   86145:c498d1090970
branch:      2.7
parent:      86142:5e1f359d54c4
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Oct 08 21:07:21 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 u'rR\'"' and
-                u'\\' in val):
+            if not self.unicode_literals and val[0] in u'\'"' and u'\\' in val:
                 val = ur'\\'.join([
                     v.replace(u'\\u', ur'\\u').replace(u'\\U', ur'\\U')
                     for v in val.split(ur'\\')
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
@@ -2830,7 +2830,7 @@
         self.check(b, a)
 
         b = """r'\\\\\\u20ac\\U0001d121\\\\u20ac'"""
-        a = """r'\\\\\\\\u20ac\\\\U0001d121\\\\u20ac'"""
+        a = """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