Commit 6f2ec18b authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #18037: Do not escape '\u' and '\U' in raw strings.

parent 2808a124
......@@ -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 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'\\')
......
......@@ -2830,7 +2830,7 @@ class Test_unicode(FixerTestCase):
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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment