From unknown Thu Aug 21 12:11:04 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#64215 <64215@debbugs.gnu.org> To: bug#64215 <64215@debbugs.gnu.org> Subject: Status: Python raw format strings highlighted as regular strings Reply-To: bug#64215 <64215@debbugs.gnu.org> Date: Thu, 21 Aug 2025 19:11:04 +0000 retitle 64215 Python raw format strings highlighted as regular strings reassign 64215 emacs submitter 64215 Joseph Garvin severity 64215 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 22 01:47:29 2023 Received: (at submit) by debbugs.gnu.org; 22 Jun 2023 05:47:29 +0000 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 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 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 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 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) MIME-Version: 1.0 From: Joseph Garvin Date: Wed, 21 Jun 2023 15:07:19 -0500 Message-ID: Subject: Python raw format strings highlighted as regular strings To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="0000000000005357ff05fea95114" 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-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) --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-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 22 02:01:09 2023 Received: (at 64215-done) by debbugs.gnu.org; 22 Jun 2023 06:01:09 +0000 Received: from localhost ([127.0.0.1]:34627 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCDNV-0004eJ-2E for submit@debbugs.gnu.org; Thu, 22 Jun 2023 02:01:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCDNT-0004dr-Pb for 64215-done@debbugs.gnu.org; Thu, 22 Jun 2023 02:01:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCDNO-0006gG-DP; Thu, 22 Jun 2023 02:01:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=l0S91sUsst8dANoYYj9/hxTFsgdQM+F7OQOax/KOIB4=; b=ZXsmGtX1AfnM jUvJ8Xa9hPIFY2BxKTsZ0fp4DBzOa57VxKS244NxFcb0DqiAcYh29t7y7hlj8Q3mDtq2ajRvhfrO0 EVbNxC1Ea0OzwsR6VaOkAiAhoBy5rjpzJ+ViwrtJByni6OCRHc1aU4iQeotPhONs3YgQpN6kudmQd N3+e5lXGhA8HeDUv9Q4TgZ3uGFTw8rWmrv959vWnos6rpFTYf/3ApUs30WTF5RUuwrbUkVgQziFRr kl9wJt3xp7Do+wfHRpVMTr4eULvfFBis7k0Q12RWQFVwB8b6CgBM5HdjRxSwBBiR90w+VND+Wydqc chjfkTriyTNeylXzx6R8/A==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCDNN-0000uZ-EA; Thu, 22 Jun 2023 02:01:01 -0400 Date: Thu, 22 Jun 2023 09:01:08 +0300 Message-Id: <835y7g3ujf.fsf@gnu.org> From: Eli Zaretskii To: Joseph Garvin In-Reply-To: (message from Joseph Garvin on Wed, 21 Jun 2023 15:07:19 -0500) Subject: Re: bug#64215: Python raw format strings highlighted as regular strings References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 64215-done Cc: 64215-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Joseph Garvin > Date: Wed, 21 Jun 2023 15:07:19 -0500 > > 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 Thanks. You are using a pretest version of Emacs 28.1. I can reproduce the problem in Emacs 28, but not in what will soon become Emacs 29. So I think we already fixed this problem, and I'm therefore closing this bug. From unknown Thu Aug 21 12:11:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 20 Jul 2023 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator