[3.13] gh-154711: Strip comments after escaped quotes in f-string debug text - #158310
Open
ArneshBanerjee wants to merge 1 commit into
Open
ArneshBanerjee wants to merge 1 commit into
ArneshBanerjee wants to merge 1 commit into
Conversation
…ng debug text When a replacement field ended with a string that had an escaped quote and was followed by a comment, the comment leaked into the debug f-string output. The comment detection loop in set_fstring_expr skips escaped characters, but the comment stripping loop did not. So an escaped quote left the scanner thinking it was still inside a string, and the comment was never removed. This makes the stripping loop skip escaped characters the same way the detection loop does. 3.14 and later already have this fix from pythongh-154719.
ArneshBanerjee
requested review from
lysnikolaou and
pablogsal
as code owners
September 28, 2026 02:35
This was referenced Sep 28, 2026
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.
When a replacement field ended with a string that had an escaped quote and was followed by a comment, the comment leaked into the debug f-string output.
The comment detection loop in
set_fstring_exprskips escaped characters, but the comment stripping loop did not. So an escaped quote left the scanner thinking it was still inside a string, and the comment was never removed.This makes the stripping loop skip escaped characters the same way the detection loop does. 3.14 and 3.15 already have the same fix from the gh-154719 backports, and main is not affected after gh-153569, so this is 3.13 only. The tests for main are in #158220.
Replaces #154914.