[Python-bugs-list] [Bug #110866] re group self-reference weird behavior (PR#2)

noreply@sourceforge.net noreply@sourceforge.net
Sun, 8 Oct 2000 13:46:26 -0700


Bug #110866, was updated on 2000-Aug-01 14:41
Here is a current snapshot of the bug.

Project: Python
Category: Modules
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Summary: re group self-reference weird behavior (PR#2)

Details: Jitterbug-Id: 2
Submitted-By: guido@python.org
Date: Mon, 12 Jul 1999 15:03:24 -0400 (EDT)
Version: 1.5.2
OS: Unix, Windows


Try the following:

import re
re.search("((.)\\1+)","a")

This isn't proper syntax (you shouldn't reference a group
inside itself), but it seems to hang -- in fact it takes
several minutes to execute.

Possibly it runs out of some resource on its path to infinite
recursion and then backtracks?


====================================================================
Audit trail:
Mon Jul 12 15:33:07 1999	guido	moved from incoming to open
Mon Jul 12 19:02:35 1999	guido	changed notes
Thu Jul 13 20:28:48 2000	fdrake	changed notes
Thu Jul 13 20:28:48 2000	fdrake	changed notification
Thu Jul 13 20:28:48 2000	fdrake	moved from open to 3rdpartybug

Follow-Ups:

Date: 2000-Aug-01 14:41
By: none

Comment:
AMK: pcre bug that's been fixed in more recent releases, but that's no longer
relevant with SRE in the picture.
-------------------------------------------------------

Date: 2000-Aug-09 02:27
By: effbot

Comment:
on the other hand, SRE says "nothing to repeat" -- which isn't really what it should do.  Looks like the width calculation messes up on GROUPREF's...

I've reassigned it to myself!
-------------------------------------------------------

Date: 2000-Sep-30 21:31
By: gvanrossum

Comment:
Fredrik, this is almost 2 months old now. Did you ever fix this?
-------------------------------------------------------

Date: 2000-Oct-08 03:03
By: effbot

Comment:
PRE still hangs, SRE always fails (an undefined group
simply cannot match anything...)
-------------------------------------------------------

Date: 2000-Oct-08 10:49
By: tim_one

Comment:
Sorry, I opened this again:  that, e.g., r"(a\1)" can never match is better than the earlier behavior, but it *should* be treated as Guido originally characterized it:  as an ill-formed regexp.  That is, it should raise an exception at regexp compile time, same as r"[a" or r"(a" etc.  A reference to group N before group N has been closed simply doesn't make sense, and is certainly a user error.
-------------------------------------------------------

Date: 2000-Oct-08 13:46
By: none

Comment:
Fair enough.  I can fix this.  But not in time for 2.0 final...

</F>
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=110866&group_id=5470