summaryrefslogtreecommitdiffstats
path: root/Lib/re
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-06-14 10:26:20 (GMT)
committerGitHub <noreply@github.com>2023-06-14 10:26:20 (GMT)
commit67f69dba0a2adc68c631bad5d970bdd22fc05d91 (patch)
tree7d4a62db48b6e699597f01119286e0d1a740e747 /Lib/re
parentfb655e0c4581ca4bed80db0a083884b29fe142d2 (diff)
downloadcpython-67f69dba0a2adc68c631bad5d970bdd22fc05d91.zip
cpython-67f69dba0a2adc68c631bad5d970bdd22fc05d91.tar.gz
cpython-67f69dba0a2adc68c631bad5d970bdd22fc05d91.tar.bz2
gh-105687: Remove deprecated objects from `re` module (#105688)
Diffstat (limited to 'Lib/re')
-rw-r--r--Lib/re/__init__.py21
-rw-r--r--Lib/re/_compiler.py2
-rw-r--r--Lib/re/_constants.py3
-rw-r--r--Lib/re/_parser.py3
4 files changed, 3 insertions, 26 deletions
diff --git a/Lib/re/__init__.py b/Lib/re/__init__.py
index 4515650..d6fccd5 100644
--- a/Lib/re/__init__.py
+++ b/Lib/re/__init__.py
@@ -130,7 +130,7 @@ import _sre
# 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",
@@ -150,7 +150,6 @@ class RegexFlag:
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 # unknown purpose, deprecated
DEBUG = _compiler.SRE_FLAG_DEBUG # dump pattern after compilation
__str__ = object.__str__
_numeric_repr_ = hex
@@ -233,17 +232,6 @@ def purge():
_cache2.clear()
_compile_template.cache_clear()
-def template(pattern, flags=0):
- "Compile a template pattern, returning a Pattern object, deprecated"
- import warnings
- warnings.warn("The re.template() function is deprecated "
- "as it is an undocumented function "
- "without an obvious purpose. "
- "Use re.compile() instead.",
- DeprecationWarning)
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning) # warn just once
- return _compile(pattern, flags|T)
# SPECIAL_CHARS
# closing ')', '}' and ']'
@@ -297,13 +285,6 @@ def _compile(pattern, flags):
return pattern
if not _compiler.isstring(pattern):
raise TypeError("first argument must be string or compiled pattern")
- if flags & T:
- import warnings
- warnings.warn("The re.TEMPLATE/re.T flag is deprecated "
- "as it is an undocumented flag "
- "without an obvious purpose. "
- "Don't use it.",
- DeprecationWarning)
p = _compiler.compile(pattern, flags)
if flags & DEBUG:
return p
diff --git a/Lib/re/_compiler.py b/Lib/re/_compiler.py
index d8e0d2f..d0a4c55 100644
--- a/Lib/re/_compiler.py
+++ b/Lib/re/_compiler.py
@@ -101,8 +101,6 @@ def _compile(code, 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 d8718d3..d8e483a 100644
--- a/Lib/re/_constants.py
+++ b/Lib/re/_constants.py
@@ -13,7 +13,7 @@
# update when constants are added or removed
-MAGIC = 20221023
+MAGIC = 20230612
from _sre import MAXREPEAT, MAXGROUPS
@@ -204,7 +204,6 @@ CH_UNICODE = {
}
# flags
-SRE_FLAG_TEMPLATE = 1 # template mode (unknown purpose, deprecated)
SRE_FLAG_IGNORECASE = 2 # case insensitive
SRE_FLAG_LOCALE = 4 # honour system locale
SRE_FLAG_MULTILINE = 8 # treat target as multiline string
diff --git a/Lib/re/_parser.py b/Lib/re/_parser.py
index 5709acb..6c8a4ec 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 State:
# keeps track of state for parsing