Bugs item #1177831, was opened at 2005-04-06 11:06 Message generated for change (Comment added) made by akuchling You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1177831&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. >Category: Regular Expressions Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: André Malo (ndparker) >Assigned to: A.M. Kuchling (akuchling) 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. ---------------------------------------------------------------------- >Comment By: A.M. Kuchling (akuchling) Date: 2005-06-02 09:41 Message: Logged In: YES user_id=11375 Thank you for your excellent explanation and suggested fix. I've applied the fix to both CVS HEAD and 2.4-maint, and added a test case that exercises groups greater than 1. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1177831&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com