From 07360df481adeacfc2b7a1a7f89ae9a76e86b725 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 30 Mar 2015 01:01:48 +0300 Subject: Issue #14260: The groupindex attribute of regular expression pattern object now is non-modifiable mapping. --- Lib/test/test_re.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Lib/test/test_re.py') diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 020656a62a..5b716125f9 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -577,6 +577,14 @@ class ReTests(unittest.TestCase): self.assertEqual(re.match("(a)", "a").regs, ((0, 1), (0, 1))) self.assertTrue(re.match("(a)", "a").re) + # Issue 14260. groupindex should be non-modifiable mapping. + p = re.compile(r'(?i)(?Pa)(?Pb)') + self.assertEqual(sorted(p.groupindex), ['first', 'other']) + self.assertEqual(p.groupindex['other'], 2) + with self.assertRaises(TypeError): + p.groupindex['other'] = 0 + self.assertEqual(p.groupindex['other'], 2) + def test_special_escapes(self): self.assertEqual(re.search(r"\b(b.)\b", "abcd abc bcd bx").group(1), "bx") -- cgit v1.2.1