[Python-checkins] python/dist/src/Lib/test test_re.py,1.40,1.41

niemeyer@users.sourceforge.net niemeyer@users.sourceforge.net
Sun, 27 Apr 2003 06:25:23 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv24491/Lib/test

Modified Files:
	test_re.py 
Log Message:
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.


Index: test_re.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** test_re.py	27 Apr 2003 12:34:14 -0000	1.40
--- test_re.py	27 Apr 2003 13:25:20 -0000	1.41
***************
*** 296,299 ****
--- 296,306 ----
                           ('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")