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: Laurence Warne
Subject: bug#56757: 29.0.50; Python f-string font-lock logic is incomplete
Date: Tue, 6 Sep 2022 11:08:32 +0100

Hi, I've attached a patch fixing up this test. The difference occurred with:
rf"""\x12 S \n \u1234 \U00010348 \N{Plus-Minus Sign}"""
(and equivalent variants: the same string but starting with fr""", fr''', rf''').

The patch treats "{Plus-Minus Sign}" as an embedded _expression_ within an f-string, causing it to be fontified differently (previously it was fontified the same as the rest of the string).  This is invalid syntax since "Plus-Minus Sign" is not a valid _expression_, so I think it's the correct behaviour since it emphasises that "{Plus-Minus Sign}" will be treated as an embedded _expression_ even though it's invalid.

I hope that makes sense, thanks, Laurence

On Mon, Sep 5, 2022 at 8:13 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
Laurence Warne <laurencewarne@gmail.com> writes:

> Hi, I've attached a patch which looks good to me locally using the above examples
> and others.
>
> In addition to the above, mixed capitalizations are also covered:
> https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals.

I think your patch makes sense, but it leads to failures in:

1 unexpected results:
   FAILED  python-font-lock-escape-sequence-multiline-string

Could you have a look at that and possibly adjust the test too (if it's
the test that's wrong here)?

Attachment: 0001-Apply-syntax-highlighting-for-all-python-f-strings.patch
Description: Text Data


reply via email to

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