[ python-Bugs-1177831 ] (?(id)yes|no) only works when referencing
the first group
SourceForge.net
noreply at sourceforge.net
Wed Apr 6 17:06:59 CEST 2005
Bugs item #1177831, was opened at 2005-04-06 17:06
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1177831&group_id=5470
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: André Malo (ndparker)
Assigned to: Nobody/Anonymous (nobody)
Summary: (?(id)yes|no) only works when referencing the first group
Initial Comment:
(?(id)yes|no) only works when referencing the first group
Referencing other marked groups may lead to weird results.
The problem is, that the compiler stores the following
code:
<op> <mark> <skip> ...
(op = GROUPREF_EXISTS)
while the matcher expects:
<op> <group> <skip> ...
where group is <number of paren -1> and <mark> is
<group * 2>.
This is the problematic code in sre_compile.py (1.57):
168 elif op is GROUPREF_EXISTS:
169 emit(OPCODES[op])
170 emit((av[0]-1)*2)
171 skipyes = _len(code); emit(0)
172 _compile(code, av[1], flags)
changing line 170 to
emit(av[0]-1)
fixes the bug.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1177831&group_id=5470
More information about the Python-bugs-list
mailing list