diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-04-06 16:53:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 16:53:50 (GMT) |
commit | b09184bf05b07b77c5ecfedd4daa846be3cbf0a9 (patch) | |
tree | 55859571882a7468d2d5ab33288b16ca1536776b /Lib/re | |
parent | da922409ac3e65c6bf2911401c7dfdf8ee6e0036 (diff) | |
download | cpython-b09184bf05b07b77c5ecfedd4daa846be3cbf0a9.zip cpython-b09184bf05b07b77c5ecfedd4daa846be3cbf0a9.tar.gz cpython-b09184bf05b07b77c5ecfedd4daa846be3cbf0a9.tar.bz2 |
bpo-47211: Remove function re.template() and flag re.TEMPLATE (GH-32300)
They were undocumented and never working.
Diffstat (limited to 'Lib/re')
-rw-r--r-- | Lib/re/__init__.py | 8 | ||||
-rw-r--r-- | Lib/re/_compiler.py | 2 | ||||
-rw-r--r-- | Lib/re/_constants.py | 2 | ||||
-rw-r--r-- | Lib/re/_parser.py | 3 |
4 files changed, 2 insertions, 13 deletions
diff --git a/Lib/re/__init__.py b/Lib/re/__init__.py index b887722..c9b5114 100644 --- a/Lib/re/__init__.py +++ b/Lib/re/__init__.py @@ -129,7 +129,7 @@ import functools # public symbols __all__ = [ "match", "fullmatch", "search", "sub", "subn", "split", - "findall", "finditer", "compile", "purge", "template", "escape", + "findall", "finditer", "compile", "purge", "escape", "error", "Pattern", "Match", "A", "I", "L", "M", "S", "X", "U", "ASCII", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL", "VERBOSE", "UNICODE", "NOFLAG", "RegexFlag", @@ -148,8 +148,6 @@ class RegexFlag: MULTILINE = M = _compiler.SRE_FLAG_MULTILINE # make anchors look for newline DOTALL = S = _compiler.SRE_FLAG_DOTALL # make dot match newline VERBOSE = X = _compiler.SRE_FLAG_VERBOSE # ignore whitespace and comments - # sre extensions (experimental, don't rely on these) - TEMPLATE = T = _compiler.SRE_FLAG_TEMPLATE # disable backtracking DEBUG = _compiler.SRE_FLAG_DEBUG # dump pattern after compilation __str__ = object.__str__ _numeric_repr_ = hex @@ -231,10 +229,6 @@ def purge(): _cache.clear() _compile_repl.cache_clear() -def template(pattern, flags=0): - "Compile a template pattern, returning a Pattern object" - return _compile(pattern, flags|T) - # SPECIAL_CHARS # closing ')', '}' and ']' # '-' (a range in character set) diff --git a/Lib/re/_compiler.py b/Lib/re/_compiler.py index bedd4b8..5b4c4a3 100644 --- a/Lib/re/_compiler.py +++ b/Lib/re/_compiler.py @@ -147,8 +147,6 @@ def _compile(data, pattern, flags): else: emit(ANY) elif op in REPEATING_CODES: - if flags & SRE_FLAG_TEMPLATE: - raise error("internal: unsupported template operator %r" % (op,)) if _simple(av[2]): emit(REPEATING_CODES[op][2]) skip = _len(code); emit(0) diff --git a/Lib/re/_constants.py b/Lib/re/_constants.py index 327ba54..4c7e93e 100644 --- a/Lib/re/_constants.py +++ b/Lib/re/_constants.py @@ -202,7 +202,6 @@ CH_UNICODE = { } # flags -SRE_FLAG_TEMPLATE = 1 # template mode (disable backtracking) SRE_FLAG_IGNORECASE = 2 # case insensitive SRE_FLAG_LOCALE = 4 # honour system locale SRE_FLAG_MULTILINE = 8 # treat target as multiline string @@ -245,7 +244,6 @@ if __name__ == "__main__": dump(f, ATCODES, "SRE") dump(f, CHCODES, "SRE") - f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE) f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE) f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE) f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE) diff --git a/Lib/re/_parser.py b/Lib/re/_parser.py index ae44118..eca2ffc 100644 --- a/Lib/re/_parser.py +++ b/Lib/re/_parser.py @@ -61,12 +61,11 @@ FLAGS = { "x": SRE_FLAG_VERBOSE, # extensions "a": SRE_FLAG_ASCII, - "t": SRE_FLAG_TEMPLATE, "u": SRE_FLAG_UNICODE, } TYPE_FLAGS = SRE_FLAG_ASCII | SRE_FLAG_LOCALE | SRE_FLAG_UNICODE -GLOBAL_FLAGS = SRE_FLAG_DEBUG | SRE_FLAG_TEMPLATE +GLOBAL_FLAGS = SRE_FLAG_DEBUG class Verbose(Exception): pass |