GNU bug report logs -
#74738
31.0.50; Freezes in Python-mode on some Python file when searching or scrolling
Previous Next
Reported by: rehan malak <rehan.malak <at> gmail.com>
Date: Sun, 8 Dec 2024 15:01:02 UTC
Severity: normal
Found in version 31.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
rehan malak wrote:
> Deleting all the "#" in the f-string of the gef.py file removes the problem on my side.
> sed -i -e 's/#0{align/0{align/g' gef.py
> sed -i -e 's/#0{width/0{width/g' gef.py
> sed -i -e 's/#07x}/07x}/g' gef.py
> sed -i -e 's/#06x}/06x}/g' gef.py
> sed -i -e 's/#04x}/04x}/g' gef.py
> sed -i -e 's/#4x}/4x}/g' gef.py
> sed -i -e 's/#8x}/8x}/g' gef.py
> sed -i -e 's/#10x}/10x}/g' gef.py
> sed -i -e 's/#x}/x}/g' gef.py
>
> Your smaller example Eli also contains a f-string with the "#".
>
> This python f-string format specifier is described here:
> https://docs.python.org/3/library/string.html#format-specification-mini-language
>
> Is this format specifier supported from the beginning ?
>
> For example :
>
> value = 0xab
> print(f"{value:x} is a value")
>
> => color syntax : is a value has the color defined by font-lock-string-face
>
> while
>
> value = 0xab
> print(f"{value:#x} is a value")
>
> => color are messed up... is has color defined by font-lock-keyword-face and a value has color defined by default face
The mechanism of the hang is still unclear, but I found the cause of
the font-lock malfunction: when using `up-list' to find the
corresponding closing brace for an opening brace in an f-string, if
the format specifier contains "#", the rest of the string is
considered a comment and the search fails. Therefore, it can be
worked around by temporarily binding `parse-sexp-ignore-comments' to
nil, as in the attached patch.
Hangs on gef.py can also be avoided with this patch, but it assumes
that the braces are properly closed. If you remove the closing braces
of expressions containing "#", it will eventually hang.
[0001-Fix-font-lock-of-Python-f-strings.patch (text/plain, attachment)]
This bug report was last modified 152 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.