[Tutor] Complaint about maximum recursion

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Oct 1 14:05:57 EDT 2003



On Wed, 1 Oct 2003, Kristoffer Erlandsson wrote:

> On Tue, Sep 30, 2003 at 11:41:36PM +0100, Jonathan Hayward http://JonathansCorner.com wrote:
> [snip]
> > line 772, in get_tag_contents_internal
> >    return my_re.findall(file_contents)
> > RuntimeError: maximum recursion limit exceeded
>
> The problem here is that regular expressions with non-greedy qualifiers
> (*? etc) are implemented using recursion. Either try rewriting them to
> greedy ones, or if you are sure you are just exceeding the limit by a
> small amount you can use sys.setrecursionlimit(n) to increase the limit.
> sys.getrecursionlimit() shows you the current limit. 1000 by default on
> my system.

Hi Jonathan,


Yes, I agree with Kristoffer --- it looks like the regular expression is
causing the recursion to overflow.  It's a known problem:

    http://www.python.org/doc/current/lib/node108.html

that occurs with nongreedy matching (*?).  But in Python 2.3, the regular
expression engine adjusted to handle certain situations in a way that
won't break.

Can you try using Python 2.3 and see if that clears up the problem?




More information about the Tutor mailing list