Skip to content

Python: Fix f-string parsing for debug = with format spec#6731

Merged
knutwannheden merged 1 commit intomainfrom
fix/fstring-debug-format-spec
Feb 13, 2026
Merged

Python: Fix f-string parsing for debug = with format spec#6731
knutwannheden merged 1 commit intomainfrom
fix/fstring-debug-format-spec

Conversation

@knutwannheden
Copy link
Contributor

Summary

  • Fix f-string parser failing on {var=:#x} (debug = + format spec, no conversion)
  • The : token was not advanced past before parsing the format spec, causing the parser to get stuck
  • Added test covering both standalone and embedded {var=:fmt} patterns

Test plan

  • New test test_debug_with_format_spec passes
  • All 41 existing f-string tests pass (no regressions)
  • Reproduces the original error parsing streamlink/src/streamlink_cli/console/windows.py

When an f-string uses the debug specifier `=` combined with a format
spec but no conversion (e.g. `{last_error=:#x}`), the `:` token was
not advanced past before parsing the format spec. This caused the
format spec parser to consume `:` instead of the actual format text,
leaving the FSTRING_MIDDLE token unconsumed and the parser stuck.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Feb 13, 2026
@knutwannheden knutwannheden merged commit 1c396f6 into main Feb 13, 2026
1 check passed
@knutwannheden knutwannheden deleted the fix/fstring-debug-format-spec branch February 13, 2026 10:04
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant