Skip to content

Fix f string expr split after #4680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MeGaGiGaGon
Copy link
Collaborator

@MeGaGiGaGon MeGaGiGaGon commented Jun 3, 2025

Description

Fixes #4677

My assumption on how the issue started is from a documentation issue on iter_fexpr_spans - the docs said "Spans are half-open ranges (left inclusive, right exclusive)", but it actually returns closed ranges. I assume the author of _get_illegal_split_indices then saw that, and added one to the range, making the ranges include the char after the f-string expr.

To fix this, I just removed that +1 on the ranges.

I looked at the other usages of iter_fexpr_spans, but all of them seem to properly use the ranges as closed.

I updated the tests that were changed by this, it was a small subsection that looks fine, and since no other code tests were effected that supports that everything else uses the spans as closed. I also fixed the docs for iter_fexpr_spans to prevent this in the future.

Checklist - did you ...

  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

string_processing: Substitutions are never put at the end of wrapped f-strings
1 participant