From df781e6a3f05f84015ffc1f354a95c29dcababe2 Mon Sep 17 00:00:00 2001 From: Fredrik Lundh Date: Mon, 2 Jul 2001 19:54:28 +0000 Subject: 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... --- Lib/test/re_tests.py | 2 ++ Lib/test/test_sre.py | 2 +- Modules/_sre.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/re_tests.py b/Lib/test/re_tests.py index 7c5dc89..d69b324 100755 --- a/Lib/test/re_tests.py +++ b/Lib/test/re_tests.py @@ -638,6 +638,8 @@ xyzabc (r'(?i)[m]+', 'MMM', SUCCEED, 'found', 'MMM'), # bug 130748: ^* should be an error (nothing to repeat) (r'^*', '', SYNTAX_ERROR), + # bug 133283: minimizing repeat bug + (r'"(?:\\"|[^"])*?"', r'"\""', SUCCEED, 'found', r'"\"'), ] try: diff --git a/Lib/test/test_sre.py b/Lib/test/test_sre.py index f133c98..e266d14 100644 --- a/Lib/test/test_sre.py +++ b/Lib/test/test_sre.py @@ -245,7 +245,7 @@ if verbose: # implementation of repeated groups. test("sre.match('(x)*', 50000*'x').span()", (0, 50000), RuntimeError) test("sre.match(r'(x)*y', 50000*'x'+'y').span()", (0, 50001), RuntimeError) -test("sre.match(r'(x)*?y', 50000*'x'+'y').span()", (0, 50001), RuntimeError) +test("sre.match(r'(x)*?y', 50000*'x'+'y').span()", (0, 50001)) from re_tests import * diff --git a/Modules/_sre.c b/Modules/_sre.c index 16629bc..910e51f 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1104,7 +1104,7 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level) /* see if the tail matches */ state->repeat = rp->prev; /* FIXME: the following fix doesn't always work (#133283) */ - if (0 && rp->pattern[2] == 65535) { + if (rp->pattern[2] == 65535) { /* unbounded repeat */ for (;;) { i = SRE_MATCH(state, pattern, level + 1); -- cgit v0.12