From 4e7be06a652680611a81d6bb1fb03ce4227ac02e Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Wed, 6 Nov 2002 14:06:53 +0000 Subject: 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. --- Lib/test/test_sre.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Lib/test/test_sre.py') diff --git a/Lib/test/test_sre.py b/Lib/test/test_sre.py index 284212c7c7..6a00affa36 100644 --- a/Lib/test/test_sre.py +++ b/Lib/test/test_sre.py @@ -78,6 +78,11 @@ test(r"""sre.match(r'(a)|(b)', 'b').start(1)""", -1) test(r"""sre.match(r'(a)|(b)', 'b').end(1)""", -1) 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'(?Pa)(?Pb)?b','ab').lastgroup""", 'a') + if verbose: print 'Running tests on sre.sub' -- cgit v1.2.1