summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2002-11-06 14:06:53 (GMT)
committerGustavo Niemeyer <gustavo@niemeyer.net>2002-11-06 14:06:53 (GMT)
commit4e7be06a652680611a81d6bb1fb03ce4227ac02e (patch)
tree0abf84675d23c70b00736be2692b59a6fd5c0222 /Lib/test
parent3c2c43341792b886740adec80ff875b1461a0ef2 (diff)
downloadcpython-4e7be06a652680611a81d6bb1fb03ce4227ac02e.zip
cpython-4e7be06a652680611a81d6bb1fb03ce4227ac02e.tar.gz
cpython-4e7be06a652680611a81d6bb1fb03ce4227ac02e.tar.bz2
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.
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/re_tests.py2
-rw-r--r--Lib/test/test_sre.py5
2 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/re_tests.py b/Lib/test/re_tests.py
index 953e4fd..d6f04f0 100755
--- a/Lib/test/re_tests.py
+++ b/Lib/test/re_tests.py
@@ -646,6 +646,8 @@ xyzabc
(r'a[^>]*?b', 'a>b', FAIL),
# 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'),
]
try:
diff --git a/Lib/test/test_sre.py b/Lib/test/test_sre.py
index 284212c..6a00aff 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'(?P<a>a)(?P<b>b)?b','ab').lastgroup""", 'a')
+
if verbose:
print 'Running tests on sre.sub'