summaryrefslogtreecommitdiff
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2003-04-27 13:25:21 +0000
committerGustavo Niemeyer <gustavo@niemeyer.net>2003-04-27 13:25:21 +0000
commit3646ab98af41f37eacf9cdc9d711327956b911f0 (patch)
tree5e411ea69c62645ccfa7be2af992764c886e3932 /Lib/test/test_re.py
parentc34f2555bd414254f941d0659ba9c229b96ec728 (diff)
downloadcpython-git-3646ab98af41f37eacf9cdc9d711327956b911f0.tar.gz
Fix for part of the problem mentioned in #725149 by Greg Chapman.
This problem is related to a wrong behavior from mark_save/restore(), which don't restore the mark_stack_base before restoring the marks. Greg's suggestion was to change the asserts, which happen to be the only recursive ops that can continue the loop, but the problem would happen to any operation with the same behavior. So, rather than hardcoding this into asserts, I have changed mark_save/restore() to always restore the stackbase before restoring the marks. Both solutions should fix these two cases, presented by Greg: >>> re.match('(a)(?:(?=(b)*)c)*', 'abb').groups() ('b', None) >>> re.match('(a)((?!(b)*))*', 'abb').groups() ('b', None, None) The rest of the bug and patch in #725149 must be discussed further.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 7ba9a1b1f9..6eebedf430 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -295,6 +295,13 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.match('^((a)c|[ab])*?c', 'abc').groups(),
('b', None))
+ def test_bug_725149(self):
+ # mark_stack_base restoring before restoring marks
+ self.assertEqual(re.match('(a)(?:(?=(b)*)c)*', 'abb').groups(),
+ ('a', None))
+ self.assertEqual(re.match('(a)((?!(b)*))*', 'abb').groups(),
+ ('a', None, None))
+
def test_finditer(self):
iter = re.finditer(r":+", "a:b::c:::d")
self.assertEqual([item.group(0) for item in iter],