Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove sre_modules
  • Loading branch information
StanFromIreland committed Jun 26, 2025
commit 5fa0085614a6de9eaa556f0e6a79a80c9942e01c
2 changes: 2 additions & 0 deletions Doc/deprecations/pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Pending removal in Python 3.15
After eight years in the :mod:`typing` module,
it has yet to be supported by any major type checker.

* :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.

* :mod:`wave`:

* The ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of
Expand Down
2 changes: 0 additions & 2 deletions Doc/deprecations/pending-removal-in-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ although there is currently no date scheduled for their removal.
underscore.
(Contributed by Serhiy Storchaka in :gh:`91760`.)

* :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.

* :mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in
Python 3.12; use the *onexc* parameter instead.

Expand Down
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ ctypes
(Contributed by Bénédikt Tran in :gh:`133866`.)


sre_*
-----

* Removed :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.
(Contributed by Stan Ulbrych in :gh:``.)


http.server
-----------

Expand Down
7 changes: 0 additions & 7 deletions Lib/sre_compile.py

This file was deleted.

7 changes: 0 additions & 7 deletions Lib/sre_constants.py

This file was deleted.

7 changes: 0 additions & 7 deletions Lib/sre_parse.py

This file was deleted.

3 changes: 0 additions & 3 deletions Lib/test/test_pyclbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ def test_others(self):
# These were once some of the longest modules.
cm('random', ignore=('Random',)) # from _random import Random as CoreGenerator
cm('pickle', ignore=('partial', 'PickleBuffer'))
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
cm('sre_parse', ignore=('dump', 'groups', 'pos')) # from sre_constants import *; property
with temporary_main_spec():
cm(
'pdb',
Expand Down
35 changes: 4 additions & 31 deletions Lib/test/test_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ def test_flags(self):
for flag in [re.I, re.M, re.X, re.S, re.A, re.L]:
self.assertTrue(re.compile(b'^pattern$', flag))

def test_sre_character_literals(self):
def test_character_literals(self):
for i in [0, 8, 16, 32, 64, 127, 128, 255, 256, 0xFFFF, 0x10000, 0x10FFFF]:
if i < 256:
self.assertTrue(re.match(r"\%03o" % i, chr(i)))
Expand Down Expand Up @@ -1476,7 +1476,7 @@ def test_sre_character_literals(self):
self.checkPatternError(r"\U0001234z", r'incomplete escape \U0001234', 0)
self.checkPatternError(r"\U00110000", r'bad escape \U00110000', 0)

def test_sre_character_class_literals(self):
def test_character_class_literals(self):
for i in [0, 8, 16, 32, 64, 127, 128, 255, 256, 0xFFFF, 0x10000, 0x10FFFF]:
if i < 256:
self.assertTrue(re.match(r"[\%o]" % i, chr(i)))
Expand Down Expand Up @@ -1504,7 +1504,7 @@ def test_sre_character_class_literals(self):
self.checkPatternError(r"[\U00110000]", r'bad escape \U00110000', 1)
self.assertTrue(re.match(r"[\U0001d49c-\U0001d4b5]", "\U0001d49e"))

def test_sre_byte_literals(self):
def test_byte_literals(self):
for i in [0, 8, 16, 32, 64, 127, 128, 255]:
self.assertTrue(re.match((r"\%03o" % i).encode(), bytes([i])))
self.assertTrue(re.match((r"\%03o0" % i).encode(), bytes([i])+b"0"))
Expand All @@ -1525,7 +1525,7 @@ def test_sre_byte_literals(self):
self.checkPatternError(br"\x1", r'incomplete escape \x1', 0)
self.checkPatternError(br"\x1z", r'incomplete escape \x1', 0)

def test_sre_byte_class_literals(self):
def test_byte_class_literals(self):
for i in [0, 8, 16, 32, 64, 127, 128, 255]:
self.assertTrue(re.match((r"[\%o]" % i).encode(), bytes([i])))
self.assertTrue(re.match((r"[\%o8]" % i).encode(), bytes([i])))
Expand Down Expand Up @@ -2927,33 +2927,6 @@ def test_disallow_instantiation(self):
pat = re.compile("")
check_disallow_instantiation(self, type(pat.scanner("")))

def test_deprecated_modules(self):
deprecated = {
'sre_compile': ['compile', 'error',
'SRE_FLAG_IGNORECASE', 'SUBPATTERN',
'_compile_info'],
'sre_constants': ['error', 'SRE_FLAG_IGNORECASE', 'SUBPATTERN',
'_NamedIntConstant'],
'sre_parse': ['SubPattern', 'parse',
'SRE_FLAG_IGNORECASE', 'SUBPATTERN',
'_parse_sub'],
}
for name in deprecated:
with self.subTest(module=name):
sys.modules.pop(name, None)
with self.assertWarns(DeprecationWarning) as w:
__import__(name)
self.assertEqual(str(w.warning),
f"module {name!r} is deprecated")
self.assertEqual(w.filename, __file__)
self.assertIn(name, sys.modules)
mod = sys.modules[name]
self.assertEqual(mod.__name__, name)
self.assertEqual(mod.__package__, '')
for attr in deprecated[name]:
self.assertHasAttr(mod, attr)
del sys.modules[name]

@cpython_only
def test_case_helpers(self):
import _sre
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear, unittest.TestCase):

class TestPytime(unittest.TestCase):
@skip_if_buggy_ucrt_strfptime
@unittest.skipUnless(time._STRUCT_TM_ITEMS == 11, "needs tm_zone support")
@unittest.skipIf(time.altzone > 0, "System uses negative DST offset")
def test_localtime_timezone(self):

# Get the localtime and examine it for the offset and zone.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse`
modules.