mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
3c2c433417
commit
4e7be06a65
4 changed files with 33 additions and 18 deletions
|
@ -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:
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue