Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-121130: Fix f-string format specifiers with debug expressions #121150
gh-121130: Fix f-string format specifiers with debug expressions #121150
Changes from 8 commits
c371cc9
89bd65a
f4aed72
93ab4a6
b97f4fd
3333a49
899cf9a
4114e0c
88a0296
e6e0f26
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is so we merge and concatenate the Constant and JoinedStr nodes. See how the tree originally looks like here: #121150 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the tree in #121150 is false, but also running that same example with the latest status of your branch gives me the same exact one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. That tree is the correct one, but without this call it basically has a bunch of Constants all together and the Joined strings are nested (comment the code and check it out to see what I mean).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is to accommodate the case when we call this function with other things than
JoinedStr
and constantsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this happen? It probably shouldn't, but I may be missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I am flattening collections that contain new nodes in https://github.com/python/cpython/pull/121150/files#r1662410566 (it's a new call over a new array that was not happening before)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Ubuntu SSL tests with OpenSSL (1.1.1w)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Ubuntu SSL tests with OpenSSL (3.0.13)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Hypothesis tests on Ubuntu
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Address sanitizer
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Ubuntu SSL tests with OpenSSL (3.1.5)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Ubuntu / build and test
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Ubuntu SSL tests with OpenSSL (3.2.1)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Ubuntu (free-threading) / build and test
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Windows / build and test (x64)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Windows / build and test (x64)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Windows (free-threading) / build and test (x64)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Windows (free-threading) / build and test (x64)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Windows / build (arm64)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Windows / build (arm64)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Windows (free-threading) / build (arm64)
Check failure on line 216 in Parser/lexer/lexer.c
GitHub Actions / Windows (free-threading) / build (arm64)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug, as if we enter
E_DECODE
state we were not returning soon enoughThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recently came across this in another branch I'm working on. If we check for this here, we can probably remove the
if (tok->decoding_erred)
about 10 lines below, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this always be 0 here, if we've correctly reset it when the format spec is ending?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the cursor check here?