From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Garvin Newsgroups: gmane.emacs.bugs Subject: bug#64215: Python raw format strings highlighted as regular strings Date: Wed, 21 Jun 2023 15:07:19 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000005357ff05fea95114" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5525"; mail-complaints-to="usenet@ciao.gmane.io" To: 64215@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 22 07:48:32 2023 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 1qCDBG-0001C4-Vp for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 22 Jun 2023 07:48:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCDAw-0004bq-L0; Thu, 22 Jun 2023 01:48:10 -0400 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 1qCDAo-0004ZZ-VQ for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 01:48:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCDAo-0006pq-Lg for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 01:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qCDAo-000441-Gr for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 01:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Joseph Garvin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Jun 2023 05:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64215 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.168741284915422 (code B ref -1); Thu, 22 Jun 2023 05:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Jun 2023 05:47:29 +0000 Original-Received: from localhost ([127.0.0.1]:34612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCDAF-00040d-Jw for submit@debbugs.gnu.org; Thu, 22 Jun 2023 01:47:29 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qC474-0001gw-La for submit@debbugs.gnu.org; Wed, 21 Jun 2023 16:07:35 -0400 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 1qC474-0000Xa-DO for bug-gnu-emacs@gnu.org; Wed, 21 Jun 2023 16:07:34 -0400 Original-Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qC472-0005Mh-Pb for bug-gnu-emacs@gnu.org; Wed, 21 Jun 2023 16:07:34 -0400 Original-Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6b5d7e60015so576808a34.0 for ; Wed, 21 Jun 2023 13:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687378051; x=1689970051; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=e6jqErO900mCie7V4LTzmlKji397bS+ou5OGcAuXlII=; b=r7viryMh1D8rM5J31ANkxB/wvD0MzjbUexU3LnWlJiKtUQ55AMGWSp3kwDt/7PHcKF BrP9ApDY0eX6xlXm73XTKZyHeIaRz3LIwGIXrkt6nhg9sI1aQYc+gMe1FCjT8dvjPMBf b6SnaX0nNEFS52hCRQ1XVci9Si/0kg+TMFl4FIIbyJ9IkvQRaDP8nKvHMyM7rxx94cjG cQR2RFIKpcJiz7u/uNF97o0UbbGxBuZY7T21n9kRneUXkTf6hJo+P3RlzBhWCn0eAucr 4QblCPdhY72EoX1Sg+JDNOsdMvw4F0xarhrBkLyu01UPPfUScw9tofBZ8O/jix2tlkhM +DdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687378051; x=1689970051; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=e6jqErO900mCie7V4LTzmlKji397bS+ou5OGcAuXlII=; b=ZGF0gGhfattgTKS5goYXOUBH9X2/+59yt7LJGvAVKlEmagHmcMTm1bEBYGI4lRktws Xz0DfK5OEjhZ4jSsOMuIgHjqJp2+vXXctGZs4yy9K7WO/NQ63NiDhQIPrUf1V0YSYZ0u XW1Mh3rOY79Fvt7QUjIRp0FvNVOmZ5Ljt31IYVPB/zD51tPMergf43Nl9ehe1pFaKHG2 Z/g85tIw+89j+nVxAofGg9+QGGdhRt/xF8bEok8hm0Oj0UBzT+7WYlvDFTncBWmWJepH swKCrhGOQHX8StahTUyn55lzReUdecI8pw2ejHROm77iU8zm62KNwA0zcwqFtOpPUpbD UeiQ== X-Gm-Message-State: AC+VfDw21T+0Sj6gNKQ4c+V+eyOKdvCdD5CjkkFZoCkjb0NyVIhV1Rky YEp93oEWANZRiJ++U/e3nOnTFl3nh9zMa7kf3ZpN6d6IIKs= X-Google-Smtp-Source: ACHHUZ5P+wqwrLCDNEPwqXLPWZjNZLEYaR1WRvf2rJ9HCzhRFJytH2zd4+6/pkJJKglNoMi6gENymSTAHUlDiLFelhc= X-Received: by 2002:a9d:5915:0:b0:6b1:604f:3f22 with SMTP id t21-20020a9d5915000000b006b1604f3f22mr14817734oth.2.1687378050896; Wed, 21 Jun 2023 13:07:30 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::330; envelope-from=k04jg02@gmail.com; helo=mail-ot1-x330.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 22 Jun 2023 01:47:26 -0400 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:263858 Archived-At: --0000000000005357ff05fea95114 Content-Type: text/plain; charset="UTF-8" Start emacs with `emacs -Q`, press C-x C-f and type in a filename that ends in .py like "foo.py". Then type in: x = 3 rf"hello {x} world" The whole string will be colored as a string literal. r means "raw" which means no escape sequences and f means this is a format string where we can interpolate variables like x. Delete the leading 'r' and the highlighting will change so that {x} is not highlighted, since it's code. However, raw and format strings are not mutually exclusive and it should be considered code in both cases. If you run the snippet above in the interpreter you will get "hello 3 world". In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2021-05-14 built on eruv Repository revision: efc24f1e0bb127481bcc9c3054c57c4cd3c99aa9 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12013000 System Description: Ubuntu 20.04.6 LTS --0000000000005357ff05fea95114 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Start emacs with `emacs -Q`, press C-x C-f and type in a f= ilename that
ends in .py like "foo.py". Then type in:

x= =3D 3
rf"hello {x} world"

The whole= string will be colored as a string literal. r means "raw" which = means no escape sequences and f means this is a format string where we can = interpolate variables like x. Delete the leading 'r' and the highli= ghting will change so that {x} is not highlighted, since it's code. How= ever, raw and format strings are not mutually exclusive and it should be co= nsidered code in both cases. If you run the snippet above in the interprete= r you will get "hello 3 world".

In GNU E= macs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0= , Xaw3d scroll bars)
=C2=A0of 2021-05-14 built on eruv
Repository rev= ision: efc24f1e0bb127481bcc9c3054c57c4cd3c99aa9
Repository branch: maste= r
Windowing system distributor 'The X.Org Foundation', version 1= 1.0.12013000
System Description: Ubuntu 20.04.6 LTS
--0000000000005357ff05fea95114--