_sre recursion limit

Darrell news at dorb.com
Sun Jul 1 15:43:45 EDT 2001


This bit of code avoids recursion in favor of a loop. Patch #101612
So it shouldn't be overly platform specific.
Fredrik gave some positive feed back that the patch was accepted,
with some reservations about it working in all cases.

So I was surprised to see it disabled and curious about the failed test
case.

Maybe I should avoid searching huge buffers.
>>> s="dog"+" "*100000 +'cat'
>>> re.search("dog.*?cat", s)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "e:\python21\lib\sre.py", line 57, in search
    return _compile(pattern, flags).search(string)
RuntimeError: maximum recursion limit exceeded


"Tim Peters"
> It's not so much the specific test case as the specific platform you run
it
> on.  C defines no way to determine whether you're "about to" run out of
> stack space, so this is nightmarish cross-platform hackery.
>
> > _sre.pyd with the 'if' enabled.  http://ezwiki.com/sre
>
> So you've tried it on *some* flavor of Windows.  And that's all?  That
would
> explain why you think it's fixed and /F doesn't <wink>.
>
>






More information about the Python-list mailing list