bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#56757: 29.0.50; Python f-string font-lock logic is incomplete


From: Dima Kogan
Subject: bug#56757: 29.0.50; Python f-string font-lock logic is incomplete
Date: Mon, 25 Jul 2022 02:06:36 -0700

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!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]