[Pythonmac-SIG] MacPy 2.1: re module error in IDE

Damon Butler Damon Butler <dbutler@impressions.com>
02 Jul 01 10:09:28 -0500


         Reply to:   Re: [Pythonmac-SIG] MacPy 2.1: re module error in IDE =
Hi, Jack,

>- Python 2.0.1 is much newer than Python 2.1, so that it's fixed in the =
latter =
>doesn't necessarily mean the fix should be in 2.1.

This is I did not know.

>Did you check 2.1 on other platforms?

I've been trusting my Windows-using Python programmer next cube over, who'=
s regex scripts with sre apparently started working under 2.1 where they =
didn't under 2.0. I just ran a simple test on WinPy 2.1 myself, however, =
and was surprised at the results. See below.

 >- There's two recursion limits in sre. One is the hard limit enforced by =
the =
>engine, the other is a check for stack overflow, which will also cause a =
>recursion limit.

So which recursion limit is it that I'm encountering here? (I typed the =
following lines into the interpreter on both Mac and Win version of Py 2.1.=
)

>>> import sre, pre, string
>>> l =3D ["XXX", "%"*20000, "XXX"]
>>> =
>>> sre_regex =3D sre.compile(r"XXX.*?XXX")
>>> match_object =3D sre_regex.search(string.join(l))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: maximum recursion limit exceeded
>>> =
>>> pre_regex =3D pre.compile(r"XXX.*XXX")
>>> match_object =3D pre_regex.search(string.join(l))
>>> match_object
<pre.MatchObject instance at 0x04619c90>

It was this discrepancy between sre and pre that I reported as a bug to =
SourceForge (#437472), and was the recursion limit error I thought had =
been fixed. Apparently not in 2.1 on either Mac or Windows, anyway, but is =
it fixed in 2.0.1?

--Damon