Py 1.5.2 -> Py 2.1.1 broke regular expression?

Roman Suzi rnd at onego.ru
Sat Aug 11 16:10:14 EDT 2001


On Sat, 11 Aug 2001, Stefan Schwarzer wrote:

>Hello
>
>I have a program which _ran fine with Python 1.5.2_ but fails with Python
>2.1.1. Its purpose is to extract IRC log sessions from several log files
>and sort them into one file in the correct order (by date/time).
>
>To do this, it uses (in effect) something like
>  re.compile(pattern).findall(log_lines)
>
>That works fine with the pattern string
>  ^Session Start: \w{3} \w{3} .*?^Session Close: \w{3} \w{3} .*?$
>but raises a
>  RuntimeError: maximum recursion limit exceeded
>in re.compile(pattern).findall(log_lines) when used with the pattern
>  ^IRC log started \w{3} \w{3} .*?(?=\012IRC log started \w{3} \w{3} |\Z)
>
>First, I thought it was because of the number of IRC sessions but the program
>fails with the second pattern even for few (5) sessions. It used to handle
>much larger numbers.
>
>Any hints? A bug or a change in the regular syntax; anything else?

I too encounterd such problem even without "(?=" construct... and it
healed itself when I reduced the number of lines in the file.
I was in hurry and forgot to record conditions of trouble.
But I remember I too used cross-end-of-line patterns ("\n"-s)
but not \Z.

It is not safe in Python 2.x to let re's loose on some big file.


Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Saturday, August 11, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "After a hard day, it's nice to come home to a warm cat." _/






More information about the Python-list mailing list