GNU bug report logs - #56757
29.0.50; Python f-string font-lock logic is incomplete

Previous Next

Package: emacs;

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

From: Laurence Warne <laurencewarne <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 56757 <at> debbugs.gnu.org
Subject: bug#56757: 29.0.50; Python f-string font-lock logic is incomplete
Date: Tue, 6 Sep 2022 11:08:32 +0100
[Message part 1 (text/plain, inline)]
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 <at> gnus.org> wrote:

> Laurence Warne <laurencewarne <at> 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)?
>
>
[Message part 2 (text/html, inline)]
[0001-Apply-syntax-highlighting-for-all-python-f-strings.patch (text/x-patch, attachment)]

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.