diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-08-09 10:26:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-09 10:26:51 (GMT) |
commit | 3bb43b7b1b75154bc4e94b1fa81afe296a8150d0 (patch) | |
tree | 9a31a9314f4f6965c8662a102294b5f58ecde50e /Lib/test | |
parent | aa2ecef22a66938cba072ea57c27c63c11f79c9a (diff) | |
download | cpython-3bb43b7b1b75154bc4e94b1fa81afe296a8150d0.zip cpython-3bb43b7b1b75154bc4e94b1fa81afe296a8150d0.tar.gz cpython-3bb43b7b1b75154bc4e94b1fa81afe296a8150d0.tar.bz2 |
[3.12] gh-106052: Fix bug in the matching of possessive quantifiers (GH-106515) (#107796)
[3.12] gh-106052: Fix bug in the matching of possessive quantifiers (gh-106515)
It did not work in the case of a subpattern containing backtracking.
Temporary implement possessive quantifiers as equivalent greedy qualifiers
in atomic groups..
(cherry picked from commit 7b6e34e5baeb4162815ffa4d943b09a58e3f6580)
Diffstat (limited to 'Lib/test')
-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 50b9ad7..85541f4 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -2365,6 +2365,16 @@ class ReTests(unittest.TestCase): self.assertTrue(template_re1.match('ahoy')) self.assertFalse(template_re1.match('nope')) + def test_bug_gh106052(self): + self.assertEqual(re.match("(?>(?:ab?c)+)", "aca").span(), (0, 2)) + self.assertEqual(re.match("(?:ab?c)++", "aca").span(), (0, 2)) + self.assertEqual(re.match("(?>(?:ab?c)*)", "aca").span(), (0, 2)) + self.assertEqual(re.match("(?:ab?c)*+", "aca").span(), (0, 2)) + self.assertEqual(re.match("(?>(?:ab?c)?)", "a").span(), (0, 0)) + self.assertEqual(re.match("(?:ab?c)?+", "a").span(), (0, 0)) + self.assertEqual(re.match("(?>(?:ab?c){1,3})", "aca").span(), (0, 2)) + self.assertEqual(re.match("(?:ab?c){1,3}+", "aca").span(), (0, 2)) + @unittest.skipIf(multiprocessing is None, 'test requires multiprocessing') def test_regression_gh94675(self): pattern = re.compile(r'(?<=[({}])(((//[^\n]*)?[\n])([\000-\040])*)*' @@ -2461,6 +2471,7 @@ ATOMIC_GROUP 17: SUCCESS ''') + @unittest.expectedFailure # gh-106052 def test_possesive_repeat_one(self): self.assertEqual(get_debug_out(r'a?+'), '''\ POSSESSIVE_REPEAT 0 1 @@ -2473,6 +2484,7 @@ POSSESSIVE_REPEAT 0 1 12: SUCCESS ''') + @unittest.expectedFailure # gh-106052 def test_possesive_repeat(self): self.assertEqual(get_debug_out(r'(?:ab)?+'), '''\ POSSESSIVE_REPEAT 0 1 |