gh-151238: Check for _get_resized_exprs failure in _PyPegen_{joined,template}_str#151259
Merged
Merged
Conversation
_get_resized_exprs failure in _PyPegen_{joined,template}_str_get_resized_exprs failure in _PyPegen_{joined,template}_str
pablogsal
approved these changes
Jun 11, 2026
Member
|
Thanks @StanFromIreland |
|
Thanks @StanFromIreland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
Sorry, @StanFromIreland, I could not cleanly backport this to |
|
GH-151344 is a backport of this pull request to the 3.15 branch. |
|
GH-151345 is a backport of this pull request to the 3.14 branch. |
Member
Author
|
This doesn’t need a backport to 3.13, this was introduced as part of the t-strings implementation. The cpython/Parser/action_helpers.c Lines 1359 to 1368 in 1d74300 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
There are several cases where
_get_resized_exprscan fail and return NULL (all of which are quite rare, however):cpython/Parser/action_helpers.c
Lines 1341 to 1344 in e2bd50d
cpython/Parser/action_helpers.c
Lines 1362 to 1368 in e2bd50d
cpython/Parser/action_helpers.c
Lines 1347 to 1351 in e2bd50d
cpython/Parser/action_helpers.c
Lines 1401 to 1404 in e2bd50d
And the one triggered by the reproducer in the issue (which I test):
cpython/Parser/action_helpers.c
Lines 1383 to 1386 in e2bd50d
_PyPegen_decode_fstring_partreturns NULL because it calls_PyPegen_decode_stringwhich in turn callswarn_invalid_escape_sequencewhich triggers the failure as it tries to import modules to issue a warning, but gets aTypeError.