130130# public symbols
131131__all__ = [
132132 "match" , "fullmatch" , "search" , "sub" , "subn" , "split" ,
133- "findall" , "finditer" , "compile" , "purge" , "template" , " escape" ,
133+ "findall" , "finditer" , "compile" , "purge" , "escape" ,
134134 "error" , "Pattern" , "Match" , "A" , "I" , "L" , "M" , "S" , "X" , "U" ,
135135 "ASCII" , "IGNORECASE" , "LOCALE" , "MULTILINE" , "DOTALL" , "VERBOSE" ,
136136 "UNICODE" , "NOFLAG" , "RegexFlag" ,
@@ -150,7 +150,6 @@ class RegexFlag:
150150 DOTALL = S = _compiler .SRE_FLAG_DOTALL # make dot match newline
151151 VERBOSE = X = _compiler .SRE_FLAG_VERBOSE # ignore whitespace and comments
152152 # sre extensions (experimental, don't rely on these)
153- TEMPLATE = T = _compiler .SRE_FLAG_TEMPLATE # unknown purpose, deprecated
154153 DEBUG = _compiler .SRE_FLAG_DEBUG # dump pattern after compilation
155154 __str__ = object .__str__
156155 _numeric_repr_ = hex
@@ -233,17 +232,6 @@ def purge():
233232 _cache2 .clear ()
234233 _compile_template .cache_clear ()
235234
236- def template (pattern , flags = 0 ):
237- "Compile a template pattern, returning a Pattern object, deprecated"
238- import warnings
239- warnings .warn ("The re.template() function is deprecated "
240- "as it is an undocumented function "
241- "without an obvious purpose. "
242- "Use re.compile() instead." ,
243- DeprecationWarning )
244- with warnings .catch_warnings ():
245- warnings .simplefilter ("ignore" , DeprecationWarning ) # warn just once
246- return _compile (pattern , flags | T )
247235
248236# SPECIAL_CHARS
249237# closing ')', '}' and ']'
@@ -297,13 +285,6 @@ def _compile(pattern, flags):
297285 return pattern
298286 if not _compiler .isstring (pattern ):
299287 raise TypeError ("first argument must be string or compiled pattern" )
300- if flags & T :
301- import warnings
302- warnings .warn ("The re.TEMPLATE/re.T flag is deprecated "
303- "as it is an undocumented flag "
304- "without an obvious purpose. "
305- "Don't use it." ,
306- DeprecationWarning )
307288 p = _compiler .compile (pattern , flags )
308289 if flags & DEBUG :
309290 return p
0 commit comments