Skip to content
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

fix: respect braces better in f-string parsing #4422

Merged
merged 7 commits into from
Aug 2, 2024

Conversation

tusharsadhwani
Copy link
Contributor

@tusharsadhwani tusharsadhwani commented Jul 31, 2024

Description

Tiny inconsistency between two regexes, one had a part changed to \\[^{] whereas the other was left to be \\., causing a crash in parsing in some cases.

The regex was a bit unreasonably complex though, it doesn't need to have \\. or \\[^{] in it anyway. This simplifies the regex and makes it more compatible.

Resolves #4421

@JelleZijlstra
Copy link
Collaborator

Thanks! Could you add a changelog entry since this fixes crashes on some real-world code?

Also might be worth adding a few more test cases; I'll take a look tonight and maybe push some too.

@tusharsadhwani
Copy link
Contributor Author

This fixes the two crashing cases, but doesn't fix the incorrect parses.

Still looking into that one.

@tusharsadhwani
Copy link
Contributor Author

rf"\{"a"}" is not fixed yet, rf"\{2}" still parses wrong.

Copy link

github-actions bot commented Jul 31, 2024

diff-shades reports zero changes comparing this PR (b32f69f) to main (4b4ae43).


What is this? | Workflow run | diff-shades documentation

@JelleZijlstra
Copy link
Collaborator

I have a fix for the remaining cases locally, will put up a PR once #4423 is done.

@tusharsadhwani
Copy link
Contributor Author

@JelleZijlstra I just made a fix, see if you can find any bugs with this one?

@JelleZijlstra JelleZijlstra merged commit b1c4dd9 into psf:main Aug 2, 2024
46 checks passed
@tusharsadhwani tusharsadhwani deleted the fstring-bugfix branch August 2, 2024 18:19
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.

Crash on f-string with \{
2 participants