Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue27948

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:f-strings: allow backslashes only in the string parts, not in the expression parts
Type:behaviorStage:resolved
Components:Interpreter CoreVersions:Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: eric.smithNosy List: eric.smith, flying sheep, python-dev, serhiy.storchaka
Priority:normalKeywords:patch

Created on2016-09-03 13:24 byeric.smith, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
27948-1.differic.smith,2016-09-07 13:56review
27948-2.differic.smith,2016-09-09 11:17review
Messages (5)
msg274294 -(view)Author: Eric V. Smith (eric.smith)*(Python committer)Date: 2016-09-03 13:24
Seeissue 27921.Currently (and for 3.6 beta 1), backslashes are not allowed anywhere in f-strings. This needs to be changed to allow them in the string parts, but not in the expression parts.Also, require that the start and end of an expression be literal '{' and '}, not escapes like '\0x7b' and '\u007d'.
msg274811 -(view)Author: Eric V. Smith (eric.smith)*(Python committer)Date: 2016-09-07 13:56
This patch implements the new logic. It passes all of the fstring tests (except of course the ones that had backslashes in the expressions). I'd still like to add some more tests, because I'm not convinced the named unicode escapes are correct (f"\N{LEFT CURLY BRACE}". Because I'm now scanning the decoded utf-8 version of the string, I need to be aware of this syntax and not decide it's part of an expression (because of the braces).
msg275309 -(view)Author: Eric V. Smith (eric.smith)*(Python committer)Date: 2016-09-09 11:17
Updated patch, works against HEAD. I added a few tests and tweaked some comments. My goal is to commit this today, before the 3.6b1 cutoff. I don't think there's much risk to it.I still need to update the PEP.
msg275540 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2016-09-10 01:56
New changesetb3ac1e154cdd by Eric V. Smith in branch 'default':Issue 27948: Allow backslashes in the literal string portion of f-strings, but not in the expressions. Also, require expressions to begin and end with literal curly braces.https://hg.python.org/cpython/rev/b3ac1e154cdd
msg275541 -(view)Author: Eric V. Smith (eric.smith)*(Python committer)Date: 2016-09-10 01:59
I've fixed the code and fixed/added tests. I still need to update the docs andPEP 498. I'll create a separate issue for the docs, once I'm done with the PEP.
History
DateUserActionArgs
2022-04-11 14:58:35adminsetgithub: 72135
2016-09-19 08:56:02flying sheepsetnosy: +flying sheep
2016-09-10 01:59:14eric.smithsetstatus: open -> closed
resolution: fixed
messages: +msg275541

stage: patch review -> resolved
2016-09-10 01:56:26python-devsetnosy: +python-dev
messages: +msg275540
2016-09-09 11:17:11eric.smithsetfiles: +27948-2.diff

messages: +msg275309
2016-09-07 15:01:19serhiy.storchakasetnosy: +serhiy.storchaka
2016-09-07 13:56:20eric.smithsetstage: needs patch -> patch review
2016-09-07 13:56:03eric.smithsetfiles: +27948-1.diff
keywords: +patch
messages: +msg274811
2016-09-03 13:24:05eric.smithcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp