fix backslash in f-string · nedbat/coveragepy@01779db (original) (raw)
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -69,6 +69,9 @@ def _phys_tokens(toks: TokenInfos) -> TokenInfos: | ||
69 | 69 | # It's a multi-line string and the first line ends with |
70 | 70 | # a backslash, so we don't need to inject another. |
71 | 71 | inject_backslash = False |
72 | +elif sys.version_info >= (3, 12) and ttype == token.FSTRING_MIDDLE: | |
73 | +if ttext.split("\n", 1)[0][-1] == "\\": | |
74 | +inject_backslash = False | |
72 | 75 | if inject_backslash: |
73 | 76 | # Figure out what column the backslash is in. |
74 | 77 | ccol = len(last_line.split("\n")[-2]) - 1 |