mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
gh-100061: Proper fix of the bug in the matching of possessive quantifiers (GH-102612)
Restore the global Input Stream pointer after trying to match a sub-pattern. Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
This commit is contained in:
parent
a86df298df
commit
abd9cc52d9
4 changed files with 17 additions and 10 deletions
|
@ -2342,7 +2342,17 @@ class ReTests(unittest.TestCase):
|
|||
self.assertTrue(re.fullmatch(r'(?s:(?>.*?\.).*)\Z', "a.txt")) # reproducer
|
||||
self.assertTrue(re.fullmatch(r'(?s:(?=(?P<g0>.*?\.))(?P=g0).*)\Z', "a.txt"))
|
||||
|
||||
def test_bug_gh106052(self):
|
||||
def test_bug_gh100061(self):
|
||||
# gh-100061
|
||||
self.assertEqual(re.match('(?>(?:.(?!D))+)', 'ABCDE').span(), (0, 2))
|
||||
self.assertEqual(re.match('(?:.(?!D))++', 'ABCDE').span(), (0, 2))
|
||||
self.assertEqual(re.match('(?>(?:.(?!D))*)', 'ABCDE').span(), (0, 2))
|
||||
self.assertEqual(re.match('(?:.(?!D))*+', 'ABCDE').span(), (0, 2))
|
||||
self.assertEqual(re.match('(?>(?:.(?!D))?)', 'CDE').span(), (0, 0))
|
||||
self.assertEqual(re.match('(?:.(?!D))?+', 'CDE').span(), (0, 0))
|
||||
self.assertEqual(re.match('(?>(?:.(?!D)){1,3})', 'ABCDE').span(), (0, 2))
|
||||
self.assertEqual(re.match('(?:.(?!D)){1,3}+', 'ABCDE').span(), (0, 2))
|
||||
# gh-106052
|
||||
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))
|
||||
|
@ -2451,7 +2461,6 @@ 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
|
||||
|
@ -2464,7 +2473,6 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue