On Oct 3, 2017, at 01:35, Serhiy Storchaka <storch...@gmail.com> wrote: > >> diff --git a/Lib/string.py b/Lib/string.py >> index b46e60c38f..fedd92246d 100644 >> --- a/Lib/string.py >> +++ b/Lib/string.py >> @@ -81,7 +81,7 @@ class Template(metaclass=_TemplateMetaclass): >> delimiter = '$' >> idpattern = r'[_a-z][_a-z0-9]*' >> braceidpattern = None >> - flags = _re.IGNORECASE >> + flags = _re.IGNORECASE | _re.ASCII >> def __init__(self, template): >> self.template = template >> patched: >> import time: 1191 | 8479 | string >> Of course, this patch is not backward compatible. [a-z] doesn't match with >> 'ı' or 'ſ' anymore. >> But who cares? > > This looks like a bug fix. I'm wondering if it is worth to backport it to > 3.6. But the change itself can break a user code that changes idpattern > without touching flags. There is other way, but it should be discussed on the > bug tracker.
It’s definitely an API change, as I mention in the bug tracker. It’s *probably* safe in practice given that the documentation does say that identifiers are ASCII by default, but it also means that a client who wants to use Unicode previously didn’t have to touch flags, and after this change would now have to do so. `flags` is part of the public API. Maybe for subclasses you could say that if delimiter, idpattern, or braceidpattern are anything but the defaults, fall back to just re.IGNORECASE. Cheers, -Barry
signature.asc
Description: Message signed with OpenPGP
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com