The re.LOCALE flag and the (?L) mode modifier determine what is a letter and what characters are equal in case-insensitive mode in a byte pattern.
It only works with byte strings, not Unicode strings.
It only works in 8-bit locales, not UTF-8 or Shift-JIS. Today 8-bit locales are very rare.
It an order slower. It does not allow compile-time optimization, and at runtime calling tolower() is much slower than simple table lookup.
In the past there were issues with compiling pattern in one locale and using it in other locale and with caching, but they were fixed long time ago.
In 2014 I implemented support of re.LOCALE with Unicode strings, but it was not supported.
The only visible effect of using re.LOCALE with Unicode string (besides slowing down) was different handling of letters I, İ, ı and i on the Turkish locale. Turkish is unique among all other languages. Maybe there were other differences with normal Unicode matching, but I did not noticed them.
I still see the use of re.LOCALE in wild code. In all cases it was unnecessary.
re.LOCALE made sense when we were still using the bytes version of str(). In the Unicode world, locale support is either no longer necessary or you need to get into the really complex ICU world (but that’s outside the scope of what we can support in the stdlib)…
You’d also need to look for re.L, (?L), and (?L:) – but the inline flags can contain multiple modifiers [1] (I’m not going to atempt to make a pattern to find them!)
During the deprecation, if there is a strike of users who want to keep the feature, we can keep it. With more concrete use cases, we can better understand how it is used.
Also, while the code was mostly stable in recent years, for 3.16 I am adding new features and optimizations, and the existence of re.LOCALE means neccessarity to add special cases. It has a real maintenance cost. The earlier we will get rid of it, the better.
@Stanfromireland and @hugovk want to prolong deprecation to 3.21. Do we really need this? Is there a code that uses re.LOCALE intentionally, and it is not a bug?
Deferring removal imposes additional maintenance burden on us.