Skip to content

[3.15] gh-162140: Fix lexer assertion for nested f-string with unclosed replacement field - #162151

Open
alonfaraj wants to merge 1 commit into
python:3.15from
alonfaraj:gh-162140-fstring-level
Open

alonfaraj wants to merge 1 commit into
python:3.15from
alonfaraj:gh-162140-fstring-level

Conversation

@alonfaraj

@alonfaraj alonfaraj commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes a regression from the 3.15 backport of gh-157778 (#158047).

When a nested f-string ends while one of its { is still open, that { stays on the lexer's bracket stack. The backport worked out the position of the outer f-string's { from the current bracket count, so the extra { made it point at the wrong entry.

The fix saves the bracket level when the f-string starts and uses it instead, which is what main does.

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