re module - error with non-greedy matches

Derek Thomson derekt at dstc.qut.edu.au
Wed Jan 9 09:13:14 EST 2002


Hi,

I'm having some trouble porting a Perl program to Python. It extracts C 
functions from the source and performs some analysis.

Here's the problematic code:


extract_function = re.compile('^ \w+\(.*?\) .*? ^\{ .*? ^\}',
                               re.VERBOSE | re.MULTILINE | re.DOTALL)

functions = extract_function.findall(code)


This gives me:


Traceback (most recent call last):
   File "/home/derekt/bin/untangle", line 12, in ?
     functions = extract_function.findall(code)
RuntimeError: maximum recursion limit exceeded


This is with Python 2.2. I've seen that this issue has been raised in 
the past, but it doesn't seem to have been fixed. Is this problem with 
non-greedy regex matching being addressed? There are some entries in the 
sourceforge bug list related to this, but they seemed focused on 
workarounds and don't give me much idea if I can expect a fix.

Thanks,
Derek.




More information about the Python-list mailing list