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 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).
History
Date
User
Action
Args
2022-04-11 14:57:03
admin
set
github: 53380
2022-03-29 15:30:16
serhiy.storchaka
set
status: open -> closedversions: + Python 3.11, - Python 2.7, Python 3.7, Python 3.8messages: + resolution: out of datestage: needs patch -> resolved