Skip to content

Commit 6c5a39f

Browse files
author
LiuYinCarl
committed
fix incorrect backslash before multi-line string
1 parent 2a7d977 commit 6c5a39f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

coverage/phystokens.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ def _phys_tokens(toks: TokenInfos) -> TokenInfos:
5757
if last_ttext.endswith("\\"):
5858
inject_backslash = False
5959
elif ttype == token.STRING:
60-
if "\n" in ttext and ttext.split("\n", 1)[0][-1] == "\\":
60+
if last_line.endswith(last_ttext+"\\\n"):
61+
# Deal with special cases like such code::
62+
#
63+
# a = ["aaa",\
64+
# "bbb \
65+
# ccc"]
66+
#
67+
pass
68+
elif "\n" in ttext and ttext.split("\n", 1)[0][-1] == "\\":
6169
# It's a multi-line string and the first line ends with
6270
# a backslash, so we don't need to inject another.
6371
inject_backslash = False

0 commit comments

Comments
 (0)