From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: rehan malak Newsgroups: gmane.emacs.bugs Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Date: Thu, 12 Dec 2024 04:49:34 +0100 Message-ID: References: <868qsqf54x.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000007e612b06290a9430" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16400"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Stefan Monnier , 74738@debbugs.gnu.org To: kobarity Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 12 04:50:22 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tLaDV-00043E-S6 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 12 Dec 2024 04:50:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLaDF-0002CV-FO; Wed, 11 Dec 2024 22:50:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLaDC-0002CA-SB for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 22:50:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLaDC-0001B6-Ix for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 22:50:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:In-Reply-To:References:MIME-Version:To:Subject; bh=bOEuV6pqYzw/3gmR/p0XF6xEBRsLanv3ovGb6WADoK0=; b=IsLbuAe4wW+SySMvcS5HuSKhw0VWVb9sBgfkXLenINk7G+BwO4/ubsrguDREG0b+RXeGYY8kgi0zLWY65mFG1YiggMblrBrniXirJiIp1wViiXdbOYeYRXEInMZqoCjsDXf3vUQX3e2qhTMXrf4/sPt+Q/UvZlRXMBSSIEFgvjG/b1LdU/lQhp0QRXyb0TfYHvOlI9tCFpV4kO8IIjXIsTLXNNzQY5hds88vHhfA5Zf/1bo4/QgKYjp8bk099A8uWFuuQd8yf2xm3H4NSXsTYjR7rHaTVZwhe6GJMyHe5zohcgyvZcVy51SHGzhgtIxbe+gswg5wFF5qCnTNDdD0Tg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tLaDC-0004xN-4Z for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 22:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: rehan malak Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Dec 2024 03:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs Original-Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.173397534818882 (code B ref 74738); Thu, 12 Dec 2024 03:50:02 +0000 Original-Received: (at 74738) by debbugs.gnu.org; 12 Dec 2024 03:49:08 +0000 Original-Received: from localhost ([127.0.0.1]:37112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLaCJ-0004uU-Np for submit@debbugs.gnu.org; Wed, 11 Dec 2024 22:49:08 -0500 Original-Received: from mail-vk1-f169.google.com ([209.85.221.169]:45492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLaCF-0004ti-Md for 74738@debbugs.gnu.org; Wed, 11 Dec 2024 22:49:06 -0500 Original-Received: by mail-vk1-f169.google.com with SMTP id 71dfb90a1353d-5187f6f7bcaso38935e0c.3 for <74738@debbugs.gnu.org>; Wed, 11 Dec 2024 19:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733975278; x=1734580078; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bOEuV6pqYzw/3gmR/p0XF6xEBRsLanv3ovGb6WADoK0=; b=FMynbjhQe9/kFZPLDoO0nGuOKgEfuVujklGMKBxCnyAyICJH+DXYvGa/huNQhVcPo5 F0lF6oEJyI0cVkQtHtQrtlgqWe8ehCzZt5d7Y5AHK8HL86MwHvXUXHpG6b4WeBkSAHOp RpSZU7XevtCojix2CwAjV1hlXtborh/mhj/BhEdAbBrd4atSg0bDpp5Tdqv30jg/+yL5 vDJG+nH8mPD23Ki+CE7339gAEIFo6uWxH/UJO4/Kw8O0aXM4OmUAtuLll3Mergc7YfIa Jtir+B4MuOXJWaD+OEJqHRmJ1FMRsRudB0YJ4qNvPnZVzuf6xFJdBBKNPHPBHvzY9va5 Xr0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733975278; x=1734580078; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bOEuV6pqYzw/3gmR/p0XF6xEBRsLanv3ovGb6WADoK0=; b=YEOybIU+MoEW1Lld4o8yVTkZe6mSgEY26ozRdaKfWJEbobJXHAnaR+3sUZq+GTOUVY x+5RTGvSyQVTjw0WnfPaJ4hEAOvcU2wvBbC5ZeQCjqNqyQOPGKqAn5RtwafdjB5lDPyu O1FBxbNokk2Yzw/dOyBWpDsS8/tn3UvQ4n4Q8P8mLjWEj59yChk8nF8UJI4yRVyC9C0M zAUn/TdtNEZXq1xHOsRv+wK1idJrTBaEv6CUZKvxU+s8lHE3mR9o90ECijN39PDFHvtF MVP7IHsUwwptOFKctdLQdwHivgYaY+7SsOmxkh7swMT9qClOFkvybVDnSJmFlvWRlG3R EOpw== X-Forwarded-Encrypted: i=1; AJvYcCWRjsbFZfka45M9xXJBXTcrdUn9GTjjg0JInJ/ZY0EBnOzqiKrRS52aZzJwsBT5nZnxTGL54A==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxAXbZwgwjBJUyyJ2DzDOW1DPB4BoAnD7fwSBmB6ObQk9yQEWdG Z+zYK9ydvxktXgCC9WeiupU6pvHvBV0YfVZUxzLzZqEKF1VJjiimfStD9jY8njyKqJ1xB/yYXts cbWbhrph2q9jPKpx0kdyPEIHa2YY= X-Gm-Gg: ASbGncv13EFZZ9LlsIVzOf1L8pZQ7BqPyiUeJgff+OXH+C+qR+sS5bp1v8+S2S5HTV4 cwnklBC0mTkgXCtpl+sMTxEgh/Zzc6UVXwZw1lQ== X-Google-Smtp-Source: AGHT+IHVOBAgm8zwVkMoM5Ut0YGzoW/OpB7Ttt+pN1WM7ZTFC/wnnEWdpa0OGl9gD7arNlJEtm6vDd9QpF0qGhB8Lwc= X-Received: by 2002:a05:6122:4882:b0:518:a14e:7334 with SMTP id 71dfb90a1353d-518b5dfe3dfmr2053848e0c.12.1733975277983; Wed, 11 Dec 2024 19:47:57 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296882 Archived-At: --0000000000007e612b06290a9430 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable thanks kobarity, with your patch, I confirm that : - I can open gef.py and scroll - I get the correct font-lock-string-face in the f-string after a "#" in the format On Wed, Dec 11, 2024 at 3:24=E2=80=AFPM kobarity wrote= : > 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-l= anguage > > > > Is this format specifier supported from the beginning ? > > > > For example : > > > > value =3D 0xab > > print(f"{value:x} is a value") > > > > =3D> color syntax : is a value has the color defined by > font-lock-string-face > > > > while > > > > value =3D 0xab > > print(f"{value:#x} is a value") > > > > =3D> color are messed up... is has color defined by font-lock-keyword-f= ace > 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. > --0000000000007e612b06290a9430 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
thanks kobarity, with your patch, I confirm that :
- I can open gef.py and scroll
- I get the correct font-lock-str= ing-face in the f-string after a "#" in the format
On Wed, Dec 11, 2024 at 3:24=E2=80=AFPM kobarity <kobarity@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">rehan malak wrote:
> Deleting all the "#" in the f-string of the gef.py file remo= ves the problem on my side.
>=C2=A0 sed -i -e 's/#0{align/0{align/g' gef.py
>=C2=A0 sed -i -e 's/#0{width/0{width/g' gef.py
>=C2=A0 sed -i -e 's/#07x}/07x}/g' gef.py
>=C2=A0 sed -i -e 's/#06x}/06x}/g' gef.py
>=C2=A0 sed -i -e 's/#04x}/04x}/g' gef.py
>=C2=A0 sed -i -e 's/#4x}/4x}/g' gef.py
>=C2=A0 sed -i -e 's/#8x}/8x}/g' gef.py
>=C2=A0 sed -i -e 's/#10x}/10x}/g' gef.py
>=C2=A0 sed -i -e 's/#x}/x}/g' gef.py
>
> Your smaller example Eli also contains a f-string with the "#&quo= t;.
>
> This python f-string format specifier is described here:
> https://docs.py= thon.org/3/library/string.html#format-specification-mini-language
>
> Is this format specifier supported from the beginning ?
>
> For example :
>
> value =3D 0xab
> print(f"{value:x} is a value")
>
> =3D> color syntax : is a value=C2=A0 =C2=A0 has the color defined b= y font-lock-string-face
>
> while
>
> value =3D 0xab
> print(f"{value:#x} is a value")
>
> =3D> color are messed up... is has color defined by font-lock-keywo= rd-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.=C2=A0 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.=C2=A0 If you remove the closing braces=
of expressions containing "#", it will eventually hang.
--0000000000007e612b06290a9430--