classification
Title: Provoking infinite scanner loops
Type: Stage:
Components: Regular Expressions Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: effbot Nosy List: dschnepper, effbot, niemeyer, tim.peters
Priority: normal Keywords:

Created on 2002-07-13 19:32 by tim.peters, last changed 2003-04-22 21:30 by dschnepper. This issue is now closed.

Messages (4)
msg11563 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-07-13 19:32
From c.l.py:

"""
From: Jane Austine
Sent: Saturday, July 13, 2002 6:01 AM
To: python-list@python.org
Subject: sre.finditer break down: is this a bug?

Newly added function sre.finditer and 
(matchedObject.)finditer break down and the system 
crushes on win32 when requested for next() after 
StopIteration.

see:
>> import sre
>> fi=sre.finditer(r'\s','a b')
>> fi.next()
>> fi.next()
>> fi.next() #system halts for ever.
-- 
"""

The semantics of the underlying calliterobject aren't 
clear to me in this endcase, and I've raised that issue 
on c.l.py.

But regardless of how that's resolved,  it's easy to 
provoke the bad behavior without using finditer, and 
that should be fixed:

>>> import re
>>> s = re.compile(r'\s').scanner
>>> t = s('a b').search
>>> t()
<_sre.SRE_Match object at 0x00679F70>
>>> t()
>>> t()
>>> t()

and there it's hung.
msg11564 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-07-13 19:35
Logged In: YES 
user_id=31435

Oops -- I meant I raised the calliterobject issue on Python-
Dev, not on c.l.py.
msg11565 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2002-11-07 03:30
Logged In: YES 
user_id=7887

Fixed in the following CVS revisions: 
 
Misc/NEWS: 1.515->1.516 
Modules/_sre.c: 2.84->2.85 
 
Thank you, Tim! 
msg11566 - (view) Author: David Schnepper (dschnepper) Date: 2003-04-22 21:30
Logged In: YES 
user_id=72348

This fix needs backporting to the release-maint22 branch
History
Date User Action Args
2002-07-13 19:32:52tim.peterscreate