diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-04-29 06:47:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 06:47:11 (GMT) |
commit | 5daf70b22e72ea1a88c05975f69120b8c4e4927f (patch) | |
tree | e9e661b7d671bb41f9ec9776f7d378288d187cf4 /Lib/test/test_re.py | |
parent | 1e7b858575d0ad782939f86aae4a2fa1c29e9f14 (diff) | |
download | cpython-5daf70b22e72ea1a88c05975f69120b8c4e4927f.zip cpython-5daf70b22e72ea1a88c05975f69120b8c4e4927f.tar.gz cpython-5daf70b22e72ea1a88c05975f69120b8c4e4927f.tar.bz2 |
bpo-43908: Make re types immutable (GH-25697)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r-- | Lib/test/test_re.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index bd68958..96d0cdb 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -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(""), []) |