Commit 6cc0eabd authored by Fredrik Lundh's avatar Fredrik Lundh

-- added recursion limit (currently ~10,000 levels)

-- improved error messages
-- factored out SRE_COUNT; the same code is used by
   SRE_OP_REPEAT_ONE_TEMPLATE
-- minor cleanups
parent 791a2562
test_sre test_sre
maximum recursion limit exceeded
...@@ -264,6 +264,16 @@ for flags in [sre.I, sre.M, sre.X, sre.S, sre.L, sre.T, sre.U]: ...@@ -264,6 +264,16 @@ for flags in [sre.I, sre.M, sre.X, sre.S, sre.L, sre.T, sre.U]:
except: except:
print 'Exception raised on flag', flags print 'Exception raised on flag', flags
if verbose:
print 'Test engine limitations'
# Try nasty case that overflows the straightforward recursive
# implementation of repeated groups.
try:
assert sre.match('(x)*', 50000*'x').span() == (0, 50000)
except RuntimeError, v:
print v
from re_tests import * from re_tests import *
if verbose: if verbose:
......
This diff is collapsed.
...@@ -74,8 +74,6 @@ typedef struct { ...@@ -74,8 +74,6 @@ typedef struct {
SRE_REPEAT *repeat; /* current repeat context */ SRE_REPEAT *repeat; /* current repeat context */
/* hooks */ /* hooks */
SRE_TOLOWER_HOOK lower; SRE_TOLOWER_HOOK lower;
/* debugging */
int maxlevel;
} SRE_STATE; } SRE_STATE;
typedef struct { typedef struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment