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
Message #11 received at 74738 <at> debbugs.gnu.org (full text, mbox):
rehan malak wrote:
> Please tell me if there is a workaround without losing python syntax color ?
If you can configure Emacs to use tree-sitter, python-ts-mode would
not be affected by this problem.
Eli Zaretskii wrote:
>
> > From: rehan malak <rehan.malak <at> gmail.com>
> > Date: Sun, 8 Dec 2024 14:05:36 +0100
> >
> > I can reproduce systematically this freeze dealing with a 10000lines
> > Python file :
> >
> > wget https://raw.githubusercontent.com/hugsy/gef/refs/heads/main/gef.py
> > emacs -Q gef.py
It seems to be reproducible after the following commit:
commit 3b3274a85c2f5df21d76d82e0d7740005aa84fdf
Author: Stefan Monnier <monnier <at> iro.umontreal.ca>
Date: Fri Oct 16 14:03:59 2020 -0400
* lisp/progmodes/python.el: Teach f-strings to `font-lock`
(python--f-string-p, python--font-lock-f-strings): New functions.
(python-font-lock-keywords-maximum-decoration): Use them.
> A much smaller reproducer is attached below. Just visiting it freezes
> Emacs. But if I change the line marked below:
>
> @classmethod
> def is_valid(cls, _: pathlib.Path) -> bool:
> raise NotImplementedError
>
> def __str__(self) -> str:
> >>>>> return f"{self.name}('{self.path.absolute()}', entry @ {self.entry_point:#x})"
>
> to say this instead:
>
> return self.name
>
> the problem goes away. So it is something in that complex expression
> that trips syntax-ppss.
>
> Stefan and kobarity, any suggestions or ideas?
I could not reproduce the freeze, but it took several seconds to visit
the reproducer. It appears to be possible to work around this by
simply removing the format specifier ":#x".
return f"{self.name}('{self.path.absolute()}', entry @ {self.entry_point})"
So there may be a problem with font-lock when there is an f-string
format specifier, but I have not found the root cause yet.
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.