mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-43908: Make re types immutable (GH-25697)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
1e7b858575
commit
5daf70b22e
3 changed files with 17 additions and 3 deletions
|
@ -2190,6 +2190,18 @@ class ImplementationTest(unittest.TestCase):
|
|||
Test implementation details of the re module.
|
||||
"""
|
||||
|
||||
@cpython_only
|
||||
def test_immutable(self):
|
||||
# bpo-43908: check that re types are immutable
|
||||
with self.assertRaises(TypeError):
|
||||
re.Match.foo = 1
|
||||
with self.assertRaises(TypeError):
|
||||
re.Pattern.foo = 1
|
||||
with self.assertRaises(TypeError):
|
||||
pat = re.compile("")
|
||||
tp = type(pat.scanner(""))
|
||||
tp.foo = 1
|
||||
|
||||
def test_overlap_table(self):
|
||||
f = sre_compile._generate_overlap_table
|
||||
self.assertEqual(f(""), [])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue