File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,11 @@ def _phys_tokens(toks: TokenInfos) -> TokenInfos:
57
57
if last_ttext .endswith ("\\ " ):
58
58
inject_backslash = False
59
59
elif ttype == token .STRING :
60
- if last_line .endswith (last_ttext + "\\ \n " ):
60
+ if (last_line .endswith ("\\ \n " ) and
61
+ last_line .rstrip (" \\ \n " ).endswith (last_ttext )):
61
62
# Deal with special cases like such code::
62
63
#
63
- # a = ["aaa",\
64
+ # a = ["aaa",\ # there may be zero or more blanks between "," and "\".
64
65
# "bbb \
65
66
# ccc"]
66
67
#
@@ -69,6 +70,9 @@ def _phys_tokens(toks: TokenInfos) -> TokenInfos:
69
70
# It's a multi-line string and the first line ends with
70
71
# a backslash, so we don't need to inject another.
71
72
inject_backslash = False
73
+ elif sys .version_info >= (3 , 12 ) and ttype == token .FSTRING_MIDDLE :
74
+ if ttext .split ("\n " , 1 )[0 ][- 1 ] == "\\ " :
75
+ inject_backslash = False
72
76
if inject_backslash :
73
77
# Figure out what column the backslash is in.
74
78
ccol = len (last_line .split ("\n " )[- 2 ]) - 1
You can’t perform that action at this time.
0 commit comments