File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -755,13 +755,15 @@ attributes:
755755
756756* *idpattern * -- This is the regular expression describing the pattern for
757757 non-braced placeholders. The default value is the regular expression
758- ``(?-i :[_a-zA-Z][_a-zA-Z0-9]*) ``. If this is given and *braceidpattern * is
758+ ``(?a :[_a-zA-Z][_a-zA-Z0-9]*) ``. If this is given and *braceidpattern * is
759759 ``None `` this pattern will also apply to braced placeholders.
760760
761761 .. note ::
762762
763763 Since default *flags * is ``re.IGNORECASE ``, pattern ``[a-z] `` can match
764- with some non-ASCII characters. That's why we use local ``-i `` flag here.
764+ with some non-ASCII characters. That's why we use the local ``a `` flag
765+ here. Further, with the default *flags * value, including ``A-Z `` in the
766+ ranges is redundant, but required for backward compatibility.
765767
766768 While *flags * is kept to ``re.IGNORECASE `` for backward compatibility,
767769 you can override it to ``0 `` or ``re.IGNORECASE | re.ASCII `` when
Original file line number Diff line number Diff line change @@ -79,11 +79,14 @@ class Template(metaclass=_TemplateMetaclass):
7979 """A string class for supporting $-substitutions."""
8080
8181 delimiter = '$'
82- # r'[a-z]' matches to non-ASCII letters when used with IGNORECASE,
83- # but without ASCII flag. We can't add re.ASCII to flags because of
84- # backward compatibility. So we use local -i flag and [a-zA-Z] pattern.
82+ # r'[a-z]' matches to non-ASCII letters when used with IGNORECASE, but
83+ # without the ASCII flag. We can't add re.ASCII to flags because of
84+ # backward compatibility. So we use the ?a local flag and [a-z] pattern.
85+ # We also can't remove the A-Z ranges, because although they are
86+ # technically redundant with the IGNORECASE flag, the value is part of the
87+ # publicly documented API.
8588 # See https://bugs.python.org/issue31672
86- idpattern = r'(?-i :[_a-zA-Z][_a-zA-Z0-9]*)'
89+ idpattern = r'(?a :[_a-zA-Z][_a-zA-Z0-9]*)'
8790 braceidpattern = None
8891 flags = _re .IGNORECASE
8992
You can’t perform that action at this time.
0 commit comments