Mailing List Archive

python/dist/src/Lib/test re_tests.py,1.30,1.31 test_sre.py,1.37,1.38
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv9767/Lib/test

Modified Files:
re_tests.py test_sre.py
Log Message:
Fixed bug #470582, using a modified version of patch #527371,
from Greg Chapman.

* Modules/_sre.c
(lastmark_restore): New function, implementing algorithm to restore
a state to a given lastmark. In addition to the similar algorithm used
in a few places of SRE_MATCH, restore lastindex when restoring lastmark.
(SRE_MATCH): Replace lastmark inline restoring by lastmark_restore(),
function. Also include it where missing. In SRE_OP_MARK, set lastindex
only if i > lastmark.

* Lib/test/re_tests.py
* Lib/test/test_sre.py
Included regression tests for the fixed bugs.

* Misc/NEWS
Mention fixes.


Index: re_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/re_tests.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** re_tests.py 9 Dec 2001 16:13:15 -0000 1.30
--- re_tests.py 6 Nov 2002 14:06:52 -0000 1.31
***************
*** 647,650 ****
--- 647,652 ----
# bug 490573: minimizing repeat problem
(r'^a*?$', 'foo', FAIL),
+ # bug 470582: nested groups problem
+ (r'^((a)c)?(ab)$', 'ab', SUCCEED, 'g1+"-"+g2+"-"+g3', 'None-None-ab'),
]


Index: test_sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sre.py,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** test_sre.py 30 Jul 2002 23:27:12 -0000 1.37
--- test_sre.py 6 Nov 2002 14:06:52 -0000 1.38
***************
*** 79,82 ****
--- 79,87 ----
test(r"""sre.match(r'(a)|(b)', 'b').span(1)""", (-1, -1))

+ # bug described in patch 527371
+ test(r"""sre.match(r'(a)?a','a').lastindex""", None)
+ test(r"""sre.match(r'(a)(b)?b','ab').lastindex""", 1)
+ test(r"""sre.match(r'(?P<a>a)(?P<b>b)?b','ab').lastgroup""", 'a')
+
if verbose:
print 'Running tests on sre.sub'