Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df781e6

Browse files
author
Fredrik Lundh
committed
reapplied darryl gallion's minimizing repeat fix. I'm still not 100%
sure about this one, but test #133283 now works even with the fix in place, and so does the test suite. we'll see what comes up...
1 parent cb9be93 commit df781e6

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

Lib/test/re_tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@
638638
(r'(?i)[m]+', 'MMM', SUCCEED, 'found', 'MMM'),
639639
# bug 130748: ^* should be an error (nothing to repeat)
640640
(r'^*', '', SYNTAX_ERROR),
641+
# bug 133283: minimizing repeat bug
642+
(r'"(?:\\"|[^"])*?"', r'"\""', SUCCEED, 'found', r'"\"'),
641643
]
642644

643645
try:

Lib/test/test_sre.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def bump_num(matchobj):
245245
# implementation of repeated groups.
246246
test("sre.match('(x)*', 50000*'x').span()", (0, 50000), RuntimeError)
247247
test("sre.match(r'(x)*y', 50000*'x'+'y').span()", (0, 50001), RuntimeError)
248-
test("sre.match(r'(x)*?y', 50000*'x'+'y').span()", (0, 50001), RuntimeError)
248+
test("sre.match(r'(x)*?y', 50000*'x'+'y').span()", (0, 50001))
249249

250250
from re_tests import *
251251

Modules/_sre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
11041104
/* see if the tail matches */
11051105
state->repeat = rp->prev;
11061106
/* FIXME: the following fix doesn't always work (#133283) */
1107-
if (0 && rp->pattern[2] == 65535) {
1107+
if (rp->pattern[2] == 65535) {
11081108
/* unbounded repeat */
11091109
for (;;) {
11101110
i = SRE_MATCH(state, pattern, level + 1);

0 commit comments

Comments
 (0)