Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1322f9e

Browse files
Issue #18037: Do not escape '\u' and '\U' in raw strings.
2 parents 245c765 + 5e59676 commit 1322f9e

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

Lib/lib2to3/fixes/fix_unicode.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def transform(self, node, results):
2828
return new
2929
elif node.type == token.STRING:
3030
val = node.value
31-
if (not self.unicode_literals and val[0] in 'rR\'"' and
32-
'\\' in val):
31+
if not self.unicode_literals and val[0] in '\'"' and '\\' in val:
3332
val = r'\\'.join([
3433
v.replace('\\u', r'\\u').replace('\\U', r'\\U')
3534
for v in val.split(r'\\')

Lib/lib2to3/tests/test_fixers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2889,7 +2889,7 @@ def test_native_literal_escape_u(self):
28892889
self.check(b, a)
28902890

28912891
b = r"""r'\\\u20ac\U0001d121\\u20ac'"""
2892-
a = r"""r'\\\\u20ac\\U0001d121\\u20ac'"""
2892+
a = r"""r'\\\u20ac\U0001d121\\u20ac'"""
28932893
self.check(b, a)
28942894

28952895
def test_bytes_literal_escape_u(self):

0 commit comments

Comments
 (0)