Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix backslash in f-string #1838

Closed
wants to merge 11 commits into from
3 changes: 3 additions & 0 deletions coverage/phystokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down