From 01779db1fea8d98acb0a15ccf229768c5851b64a Mon Sep 17 00:00:00 2001 From: LiuYinCarl Date: Mon, 26 Aug 2024 05:18:51 +0000 Subject: [PATCH] fix backslash in f-string --- coverage/phystokens.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coverage/phystokens.py b/coverage/phystokens.py index 9fc36ecda..7f113a9d1 100644 --- a/coverage/phystokens.py +++ b/coverage/phystokens.py @@ -69,6 +69,9 @@ def _phys_tokens(toks: TokenInfos) -> TokenInfos: # It's a multi-line string and the first line ends with # a backslash, so we don't need to inject another. inject_backslash = False + elif sys.version_info >= (3, 12) and ttype == token.FSTRING_MIDDLE: + if ttext.split("\n", 1)[0][-1] == "\\": + inject_backslash = False if inject_backslash: # Figure out what column the backslash is in. ccol = len(last_line.split("\n")[-2]) - 1