[Python-Dev] Time for 2.3.3?

Tim Peters tim.one at comcast.net
Fri Nov 21 14:56:42 EST 2003


[Barry]
> Yep, you're right.  If I hack _sre.c with the patch below, I think I
> get something closer to what we expect to see.
>
> % ./python
> Python 2.3.3a0 (#5, Nov 21 2003, 14:26:25)
> [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import _sre
> [24583 refs]
> >>> _sre.RECURSION_LIMIT
> 10000
> [24585 refs]
>
> ...
>
> ======================================================================
> ERROR: test_bug_418626 (__main__.ReTests)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "Lib/test/test_re.py", line 410, in test_bug_418626
>     self.assertEqual(re.search('(a|b)*?c', 10000*'ab'+'cd').end(0),
>   20001) File "/home/barry/projects/python23/Lib/sre.py", line 137,
>     in search return _compile(pattern, flags).search(string)
> RuntimeError: maximum recursion limit exceeded
>
> ======================================================================
> ERROR: test_stack_overflow (__main__.ReTests)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "Lib/test/test_re.py", line 420, in test_stack_overflow
>     self.assertEqual(re.match('(x)*', 50000*'x').group(1), 'x')
>   File "/home/barry/projects/python23/Lib/sre.py", line 132, in match
>     return _compile(pattern, flags).match(string)
> RuntimeError: maximum recursion limit exceeded

Yup, that's how they fail on Windows today, and is how they're *expected* to
fail everywhere today.

> I'll leave it to someone else to check in the proper fix.

I expect Anthony has the best shot at understanding why he did what he did
before, so has the best shot at undoing it too without creating more new
problems.

> (But does anybody else like exposing RECURSION_LIMIT in the
> _sre module?)

For 2.3 maint it would be a new feature, so probably not.

For 2.4, I believe all this code has become a mass of decoys (that is, it's
still there, but is no longer used; I don't know why it hasn't been
deleted) -- Gustavo reworked sre to stop using C-level recursion.

BTW, Gustavo, we get a big pile of compiler warnings on the trunk (2.4
development) in _sre.c now, on Windows, and apparently under
some-but-not-all gcc flavors.  How about cleaning those up?  See:

    http://mail.python.org/pipermail/python-dev/2003-October/039059.html




More information about the Python-Dev mailing list