Skip to content

[3.13] gh-154711: Strip comments after escaped quotes in f-string debug text - #158310

Open
ArneshBanerjee wants to merge 1 commit into
python:3.13from
ArneshBanerjee:gh-154711-3.13
Open

ArneshBanerjee wants to merge 1 commit into
python:3.13from
ArneshBanerjee:gh-154711-3.13

Conversation

@ArneshBanerjee

Copy link
Copy Markdown

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 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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant