GNU bug report logs -
#56757
29.0.50; Python f-string font-lock logic is incomplete
Previous Next
Reported by: Dima Kogan <dima <at> secretsauce.net>
Date: Mon, 25 Jul 2022 09:07:02 UTC
Severity: wishlist
Tags: moreinfo, patch
Found in version 29.0.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi. Currently python-mode has syntax highlighting to display the part of
the string being interpolated (the {...} stuff) differently from the
rest of the string. The emacs python-mode has logic to detect f-strings
to turn this highlighting on/off properly. It looks like this logic is
incomplete, however: it doesn't handle ''' and """ and r strings. (It
doesn't handle b strings either, but fb'asdf' is not legal Python, so
that's fine).
This is legal Python, and {x} is expanded to '5' in each case when the
program is executed.
x = 5
ss = (f'''aaa {x} bbb''',
fr'''aaa {x} bbb''',
rf'''aaa {x} bbb''',
f"""aaa {x} bbb""",
fr"""aaa {x} bbb""",
rf"""aaa {x} bbb""",
f'aaa {x} bbb', # this is highlighted properly
fr'aaa {x} bbb',
rf'aaa {x} bbb',
f"aaa {x} bbb", # this is highlighted properly
fr"aaa {x} bbb",
rf"aaa {x} bbb",)
for s in ss:
print(s)
However the {x} is highlighted as code only on the lines marked above.
The other lines should have this highlighting also.
Thanks!
This bug report was last modified 2 years and 260 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.