Message15562
SRE does not always correctly handle groups in
alternatives in repeats. For example:
>>> re.match('((a)|b)*', 'abc').groups()
('b', '')
Group 2 should obviously never be an empty string. As I
understand it, the rule for groups inside a repeat is that
they should have the last value they matched during the
iterations of the repeat (or None if they never match), so
in the above case Group 2 should be 'a'. To fix this, it
appears that (when inside a repeat) the BRANCH
opcode must call mark_save before trying an alternative
and then call mark_restore if the alternative fails. The
attached patch does this.
|
|
Date |
User |
Action |
Args |
2007-08-23 14:12:38 | admin | link | issue725106 messages |
2007-08-23 14:12:38 | admin | create | |
|