You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Negative lookbehind ignored under re.IGNORECASE | re.LOCALE #155985
On the main branch a negative lookbehind after a character class is ignored for bytes patterns when both re.IGNORECASE and re.LOCALE are set. [b] matches b'B' under those flags, so \w(?<!b) must not match b'B', but it does. The same flag pair also lets the new [A--B] difference operator match characters that are in B.
Expected: the second line is None, which is what 3.14.4 prints.
_fuse_difference() in Lib/re/_optimizer.py rewrites <charset> (?<![B]) into a single character set carrying NEGATE without seeing the compile flags, and under this flag pair that set compiles to IN_LOC_IGNORE, which tests the whole set once per locale case.
Activity
serhiy-storchaka commentedon Aug 27, 2026
There is a deeper old bug in the engine (#156444). Fixing it also fixes this issue.