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
re.IGNORECASE | re.LOCALE: a negated character set matches the other case #156444
Expected: the second line is None, which is what 3.6 and earlier print.
charset_loc_ignore() in Modules/_sre/sre_lib.h tests the whole set once per locale case and returns true if either test matches. For a set carrying NEGATE the negation has to be applied outside that disjunction: b'B' matches because 'B' itself is not in {b, c}, though its lowercase is.
A one-member set escapes this, since it compiles to NOT_LITERAL_LOC_IGNORE and compares against both cases correctly, so [^b] is fine and two members are needed to see it.
IN_LOC_IGNORE and charset_loc_ignore() were added in 3.7 by bpo-30215 (898ff03), which moved locale case folding from compile time to match time. 3.2–3.6 are correct, 3.7 through main are affected.
The set-difference fusion new in 3.16 hits the same limitation from another direction: it rewrites A(?<![B]) into a single NEGATE-bearing set, which then compiles to IN_LOC_IGNORE. See gh-155985 and GH-155993, which avoids the fusion under these flags.
Activity
gh-156444: Fix a negated character set with IGNORECASE and LOCALE (GH…
[3.14] gh-156444: Fix a negated character set with IGNORECASE and LOC…
[3.13] gh-156444: Fix a negated character set with IGNORECASE and LOC…
pythongh-156444: Fix a negated character set with IGNORECASE and LOCA…
[3.15] gh-156444: Fix a negated character set with IGNORECASE and LOC…