RE Engine error with sub()

André Søreng andreis at stud.cs.uit.no
Fri Apr 15 07:05:27 EDT 2005


The "Internal error in regular expression engine" occurs also
in Python 2.4.0 when creating a regular expression containing
more than 9999 or's ("|").

Dennis Benzinger wrote:
> Maurice LING schrieb:
> 
>> Hi,
>>
>> I have the following codes:
>>
>> from __future__ import nested_scopes
> 
>  > [...]
> 
> Are you still using Python 2.1?
> 
> In every later version you don't need the
> "from __future__ import nested_scopes" line.
> 
> So, if you are using Python 2.1 I strongly recommend
> upgrading to Python 2.4.1.
> 
>> [...]
>> It all works well for rule count up to 800+ but when my replacement 
>> rules swells up to 1800+, it gives me a runtime error that says 
>> "Internal error in regular expression engine"... traceable to "return 
>> self.regex.sub(self, text)" in substitute() method.
>> [...]
> 
> 
> I didn't read your code, but this sounds like you have a problem with 
> the regular expression engine being recursive in Python versions < 2.4.
> Try again using Python 2.4 or later (i.e. Python 2.4.1). The new regular 
> expression engine is not recursive anymore.
> 
> Bye,
> Dennis



More information about the Python-list mailing list