You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The re module is buggy is rare cases; see attached example script.
The bug is caused by the macros LASTMARK_SAVE and LASTMARK_RESTORE which are sometimes used without the extra code that does if (state->repeat) {mark_save()/mark_restore()}.
The bug appears by mis-reporting the position of groups within a repeated match (with * or +), notably the position of some groups that matched in older repetitions but (after some backtracking) not in newer ones.
Fixed in bpo-35859 together with other bugs, but the fix was only applied to 3.11, because that bug is old and the old behavior matches the behavior in some other engines (Perl and Java).
Activity
arigo commentedon Jun 30, 2010
The re module is buggy is rare cases; see attached example script.
The bug is caused by the macros LASTMARK_SAVE and LASTMARK_RESTORE which are sometimes used without the extra code that does if (state->repeat) {mark_save()/mark_restore()}.
The bug appears by mis-reporting the position of groups within a repeated match (with * or +), notably the position of some groups that matched in older repetitions but (after some backtracking) not in newer ones.
arigo commentedon Jul 1, 2010
It's pretty trivial to turn my x.py into a unit test, of course.
serhiy-storchaka commentedon Aug 1, 2014
It looks as the nature of this bug is clear to you, Armin. Do you want to write a patch?
arigo commentedon Aug 1, 2014
It was clear to me four years ago. Now I'd have to dig again as much as you do.
serhiy-storchaka commentedon Mar 29, 2022
Fixed in bpo-35859 together with other bugs, but the fix was only applied to 3.11, because that bug is old and the old behavior matches the behavior in some other engines (Perl and Java).