https://github.com/python/cpython/commit/93809a918f3a2853e8a191b84ad844c722bee2f5
commit: 93809a918f3a2853e8a191b84ad844c722bee2f5
branch: main
author: Stan Ulbrych <[email protected]>
committer: vstinner <[email protected]>
date: 2025-07-01T17:31:07+02:00
summary:
gh-105456: Remove 3 deprecated `sre_*` modules (#135994)
files:
A Misc/NEWS.d/next/Library/2025-06-26-17-19-36.gh-issue-105456.eR9oHB.rst
D Lib/sre_compile.py
D Lib/sre_constants.py
D Lib/sre_parse.py
M Doc/deprecations/pending-removal-in-3.15.rst
M Doc/deprecations/pending-removal-in-future.rst
M Doc/whatsnew/3.15.rst
M Lib/test/test_pyclbr.py
M Lib/test/test_re.py
M Python/stdlib_module_names.h
diff --git a/Doc/deprecations/pending-removal-in-3.15.rst
b/Doc/deprecations/pending-removal-in-3.15.rst
index a76d06cce1278a..c5ca599bb04a6f 100644
--- a/Doc/deprecations/pending-removal-in-3.15.rst
+++ b/Doc/deprecations/pending-removal-in-3.15.rst
@@ -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
diff --git a/Doc/deprecations/pending-removal-in-future.rst
b/Doc/deprecations/pending-removal-in-future.rst
index 4c4a368baca955..edb672ed8ad9a2 100644
--- a/Doc/deprecations/pending-removal-in-future.rst
+++ b/Doc/deprecations/pending-removal-in-future.rst
@@ -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.
diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst
index fb3f6312798753..efc5777db884c1 100644
--- a/Doc/whatsnew/3.15.rst
+++ b/Doc/whatsnew/3.15.rst
@@ -252,6 +252,13 @@ platform
(Contributed by Alexey Makridenko in :gh:`133604`.)
+sre_*
+-----
+
+* Removed :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse`
modules.
+ (Contributed by Stan Ulbrych in :gh:`135994`.)
+
+
sysconfig
---------
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
deleted file mode 100644
index f9da61e6487869..00000000000000
--- a/Lib/sre_compile.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import warnings
-warnings.warn(f"module {__name__!r} is deprecated",
- DeprecationWarning,
- stacklevel=2)
-
-from re import _compiler as _
-globals().update({k: v for k, v in vars(_).items() if k[:2] != '__'})
diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py
deleted file mode 100644
index fa09d044292965..00000000000000
--- a/Lib/sre_constants.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import warnings
-warnings.warn(f"module {__name__!r} is deprecated",
- DeprecationWarning,
- stacklevel=2)
-
-from re import _constants as _
-globals().update({k: v for k, v in vars(_).items() if k[:2] != '__'})
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
deleted file mode 100644
index 25a3f557d44c61..00000000000000
--- a/Lib/sre_parse.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import warnings
-warnings.warn(f"module {__name__!r} is deprecated",
- DeprecationWarning,
- stacklevel=2)
-
-from re import _parser as _
-globals().update({k: v for k, v in vars(_).items() if k[:2] != '__'})
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 3e7b2cd0dc9912..bce68e6cd7a57e 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -11,7 +11,6 @@
import pyclbr
from unittest import TestCase, main as unittest_main
from test.test_importlib import util as test_importlib_util
-import warnings
StaticMethodType = type(staticmethod(lambda: None))
@@ -246,9 +245,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',
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index e9128ac1d9762d..993652d2e882cc 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -5,7 +5,6 @@
import locale
import re
import string
-import sys
import unittest
import warnings
from re import Scanner
@@ -2927,33 +2926,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
diff --git
a/Misc/NEWS.d/next/Library/2025-06-26-17-19-36.gh-issue-105456.eR9oHB.rst
b/Misc/NEWS.d/next/Library/2025-06-26-17-19-36.gh-issue-105456.eR9oHB.rst
new file mode 100644
index 00000000000000..772403a240aa00
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-06-26-17-19-36.gh-issue-105456.eR9oHB.rst
@@ -0,0 +1,2 @@
+Removed :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse`
+modules.
diff --git a/Python/stdlib_module_names.h b/Python/stdlib_module_names.h
index 56e349a544c079..63e4599c31efc3 100644
--- a/Python/stdlib_module_names.h
+++ b/Python/stdlib_module_names.h
@@ -245,9 +245,6 @@ static const char* _Py_stdlib_module_names[] = {
"socket",
"socketserver",
"sqlite3",
-"sre_compile",
-"sre_constants",
-"sre_parse",
"ssl",
"stat",
"statistics",
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]