File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -755,13 +755,15 @@ attributes:
755
755
756
756
* *idpattern * -- This is the regular expression describing the pattern for
757
757
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
759
759
``None `` this pattern will also apply to braced placeholders.
760
760
761
761
.. note ::
762
762
763
763
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.
765
767
766
768
While *flags * is kept to ``re.IGNORECASE `` for backward compatibility,
767
769
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):
79
79
"""A string class for supporting $-substitutions."""
80
80
81
81
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.
85
88
# 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]*)'
87
90
braceidpattern = None
88
91
flags = _re .IGNORECASE
89
92
You can’t perform that action at this time.
0 commit comments