Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-132661: DisallowTemplate/str concatenation after PEP 750 spec update#135996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lysnikolaou merged 36 commits intopython:mainfromt-strings:pep750-concat-update
Jul 21, 2025

Conversation

@davepeck
Copy link
Contributor

@davepeckdavepeck commentedJun 26, 2025
edited
Loading

Following thesteering council decision and correspondingupdate to PEP750, we are removing support for both implicit and explicitTemplate/str concatenation.

gpshead and efimov-mikhail reacted with rocket emoji
Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you!

@lysnikolaou
Copy link
Member

Happy to do this with your input, or happy to hand it off to you!

Happy to help out / review this PR if you wanna take a stab at it. Feel free to reach out if you have any specific questions.

davepeck reacted with thumbs up emoji

@davepeck
Copy link
ContributorAuthor

@lysnikolaou Think this is ready. The only question for me is whether we want to go further with_PyPegen_concatenate_strings().

Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you! Several small nitpicks :)

davepeck reacted with heart emoji
Copy link
Member

@lysnikolaoulysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks@davepeck for working on this! Looks great in general. Left a few unimportant comments and one more significant one about how to implement this in the parser. Also, we'll need to changeast_unparse.c aroundhttps://github.com/python/cpython/blob/main/Python/ast_unparse.c#L715.

davepeck reacted with heart emoji
@efimov-mikhail
Copy link
Member

LGTM

davepeck reacted with heart emoji

@lysnikolaou
Copy link
Member

Looks great and aaalmost there. I have one last thing I missed during my previous reviews.

If I remember correctly,https://github.com/python/cpython/blob/main/Python/codegen.c#L4084-L4093 can be removed as well, because it's only there to handleFormattedValues, which cannot happen anymore.

After that, it's gonna be good to go, promise!

davepeck reacted with thumbs up emoji

@davepeck
Copy link
ContributorAuthor

davepeck commentedJul 17, 2025
edited
Loading

If I remember correctly,https://github.com/python/cpython/blob/main/Python/codegen.c#L4084-L4093 can be removed as well, because it's only there to handleFormattedValues, which cannot happen anymore.

@lysnikolaou Ah, yes -- thank you. Removed now; tests continue to pass.

(If we prefer, I can replaceVISIT() in theelse block with a directADDOP_LOAD_CONST(). I'd probably add anassert(value->kind == Constant_kind) there, too.)

Copy link
Member

@lysnikolaoulysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good to me! Thanks@davepeck! Great work.

davepeck reacted with heart emojiefimov-mikhail reacted with rocket emoji
@lysnikolaoulysnikolaou added the needs backport to 3.14bugs and security fixes labelJul 21, 2025
@lysnikolaoulysnikolaou merged commitc5e77af intopython:mainJul 21, 2025
46 of 47 checks passed
@miss-islington-app
Copy link

Thanks@davepeck for the PR, and@lysnikolaou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@lysnikolaoulysnikolaou deleted the pep750-concat-update branchJuly 21, 2025 06:44
@miss-islington-app
Copy link

Sorry,@davepeck and@lysnikolaou, I could not cleanly backport this to3.14 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker c5e77af131aa0c8832a9ee50c4410731254e4209 3.14

@lysnikolaou
Copy link
Member

I can handle tha backport.

davepeck reacted with heart emoji

lysnikolaou added a commit to lysnikolaou/cpython that referenced this pull requestJul 21, 2025
…0 spec update (python#135996)Co-authored-by: sobolevn <mail@sobolevn.me>Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>(cherry picked from commitc5e77af)
lysnikolaou added a commit that referenced this pull requestJul 21, 2025
…50 spec update (#135996) (#136901)Co-authored-by: Dave Peck <davepeck@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
dylwil3 added a commit to astral-sh/ruff that referenced this pull requestJul 27, 2025
…19485)As of [this cpython PR](python/cpython#135996),it is not allowed to concatenate t-strings with non-t-strings,implicitly or explicitly. Expressions such as `"foo" t"{bar}"` are nowsyntax errors.This PR updates some AST nodes and parsing to reflect this change.The structural change is that `TStringPart` is no longer needed, since,as in the case of `BytesStringLiteral`, the only possibilities are thatwe have a single `TString` or a vector of such (representing an implicitconcatenation of t-strings). This removes a level of nesting from manyAST expressions (which is what all the snapshot changes reflect), andsimplifies some logic in the implementation of visitors, for example.The other change of note is in the parser. When we meet an implicitconcatenation of string-like literals, we now count the number oft-string literals. If these do not exhaust the total number ofimplicitly concatenated pieces, then we emit a syntax error. To recoverfrom this syntax error, we encode any t-string pieces as _invalid_string literals (which means we flag them as invalid, record theirrange, and record the value as `""`). Note that if at least one of thepieces is an f-string we prefer to parse the entire string as anf-string; otherwise we parse it as a string.This logic is exactly the same as how we currently treat`BytesStringLiteral` parsing and error recovery - and carries with itthe same pros and cons.Finally, note that I have not implemented any changes in theimplementation of the formatter. As far as I can tell, none are needed.I did change a few of the fixtures so that we are always concatenatingt-strings with t-strings.
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull requestAug 4, 2025
…0 spec update (python#135996)Co-authored-by: sobolevn <mail@sobolevn.me>Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
@serhiy-storchaka
Copy link
Member

Reminder about backporting.@davepeck@lysnikolaou

@encukou
Copy link
Member

GH-136901 is a backport of this pull request to the 3.14 branch.

@encukouencukou removed the needs backport to 3.14bugs and security fixes labelAug 15, 2025
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull requestAug 19, 2025
…0 spec update (python#135996)Co-authored-by: sobolevn <mail@sobolevn.me>Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull requestSep 9, 2025
… PEP 750 spec update (python#135996) (python#136901)Co-authored-by: Dave Peck <davepeck@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@sobolevnsobolevnsobolevn left review comments

@efimov-mikhailefimov-mikhailefimov-mikhail left review comments

@lysnikolaoulysnikolaoulysnikolaou approved these changes

@Eclips4Eclips4Awaiting requested review from Eclips4Eclips4 is a code owner

@tomasr8tomasr8Awaiting requested review from tomasr8tomasr8 is a code owner

@isidenticalisidenticalAwaiting requested review from isidenticalisidentical is a code owner

@pablogsalpablogsalAwaiting requested review from pablogsalpablogsal is a code owner

@JelleZijlstraJelleZijlstraAwaiting requested review from JelleZijlstraJelleZijlstra is a code owner

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

@iritkatrieliritkatrielAwaiting requested review from iritkatrieliritkatriel is a code owner

Assignees

@lysnikolaoulysnikolaou

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

8 participants

@davepeck@lysnikolaou@pablogsal@efimov-mikhail@serhiy-storchaka@encukou@JelleZijlstra@sobolevn

[8]ページ先頭

©2009-2025 Movatter.jp