GeezerVison is showing github.com — gh-155985: Do not fuse a set difference under IGNORECASE with LOCALE by fedonman · Pull Request #155993 · python/cpython
Conversation
fedonman
commented
Aug 18, 2026
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
_fuse_difference() now sees the compile flags and skips the fusion when IGNORECASE and LOCALE are both set, which is exactly when the fused set would compile to IN_LOC_IGNORE. The flags are threaded through optimize() and _walk() and recombined for a scoped group, so (?i:...) inside a re.LOCALE pattern is covered too.
$ ./python -m test test_re
Total duration: 1.3 sec
Total tests: run=170 skipped=3
Total test files: run=1/1
Result: SUCCESS
No NEWS fragment: the fusion landed earlier in this cycle (GH-152214) and has never been in a release, so there is nothing a user could have hit.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…OCALE
_fuse_difference() rewrites <flat charset A> (?<![B]) into the single
charset [NEGATE] B [NEGATE] A. That is sound where the engine walks a
set once, but SRE(charset_loc_ignore) walks it twice, once with the
lowercased character and once with the uppercased one, and matches if
either walk does. The second walk starts with the NEGATE polarity
reset, so a character that matches B in one case and A in the other
escapes the subtraction.
The pass did not see the compile flags, so it could not tell the two
apart. Thread the effective flags through optimize() and _walk(),
combining them for a scoped group, and skip the fusion when IGNORECASE
and LOCALE are both set, the condition _compiler.py already uses to
emit IN_LOC_IGNORE.
This was referenced Aug 27, 2026
|
Thank you, but this is no longer needed after fixing the underlying issue.
|
fedonman reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.