[Python-bugs-list] [ python-Bugs-581080 ] Provoking infinite scanner loops

noreply@sourceforge.net noreply@sourceforge.net
Sat, 13 Jul 2002 12:35:20 -0700


Bugs item #581080, was opened at 2002-07-13 15:32
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=581080&group_id=5470

Category: Regular Expressions
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: Fredrik Lundh (effbot)
Summary: Provoking infinite scanner loops

Initial Comment:
>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.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-07-13 15:35

Message:
Logged In: YES 
user_id=31435

Oops -- I meant I raised the calliterobject issue on Python-
Dev, not on c.l.py.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=581080&group_id=5470