mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
#6630: allow customizing flags for compiling string.Template.idpattern.
This commit is contained in:
parent
1cec3e367c
commit
056cb93e7a
3 changed files with 13 additions and 1 deletions
|
@ -81,7 +81,7 @@ class _TemplateMetaclass(type):
|
|||
'delim' : _re.escape(cls.delimiter),
|
||||
'id' : cls.idpattern,
|
||||
}
|
||||
cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
|
||||
cls.pattern = _re.compile(pattern, cls.flags | _re.VERBOSE)
|
||||
|
||||
|
||||
class Template(metaclass=_TemplateMetaclass):
|
||||
|
@ -89,6 +89,7 @@ class Template(metaclass=_TemplateMetaclass):
|
|||
|
||||
delimiter = '$'
|
||||
idpattern = r'[_a-z][_a-z0-9]*'
|
||||
flags = _re.IGNORECASE
|
||||
|
||||
def __init__(self, template):
|
||||
self.template = template
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue