mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Issue #18037: Do not escape '\u' and '\U' in raw strings.
This commit is contained in:
parent
bcce1256e3
commit
5e596769b0
2 changed files with 2 additions and 3 deletions
|
@ -28,8 +28,7 @@ class FixUnicode(fixer_base.BaseFix):
|
||||||
return new
|
return new
|
||||||
elif node.type == token.STRING:
|
elif node.type == token.STRING:
|
||||||
val = node.value
|
val = node.value
|
||||||
if (not self.unicode_literals and val[0] in 'rR\'"' and
|
if not self.unicode_literals and val[0] in '\'"' and '\\' in val:
|
||||||
'\\' in val):
|
|
||||||
val = r'\\'.join([
|
val = r'\\'.join([
|
||||||
v.replace('\\u', r'\\u').replace('\\U', r'\\U')
|
v.replace('\\u', r'\\u').replace('\\U', r'\\U')
|
||||||
for v in val.split(r'\\')
|
for v in val.split(r'\\')
|
||||||
|
|
|
@ -2830,7 +2830,7 @@ class Test_unicode(FixerTestCase):
|
||||||
self.check(b, a)
|
self.check(b, a)
|
||||||
|
|
||||||
b = r"""r'\\\u20ac\U0001d121\\u20ac'"""
|
b = r"""r'\\\u20ac\U0001d121\\u20ac'"""
|
||||||
a = r"""r'\\\\u20ac\\U0001d121\\u20ac'"""
|
a = r"""r'\\\u20ac\U0001d121\\u20ac'"""
|
||||||
self.check(b, a)
|
self.check(b, a)
|
||||||
|
|
||||||
def test_bytes_literal_escape_u(self):
|
def test_bytes_literal_escape_u(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue