mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-109631: Allow interruption of short repeated regex matches (GH-109867)
Counting for signal checking now continues in new match from the point where it ended in the previous match instead of starting from 0.
This commit is contained in:
parent
7c61a361fc
commit
8ac2085b80
3 changed files with 8 additions and 2 deletions
|
|
@ -564,7 +564,7 @@ SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel)
|
|||
Py_ssize_t alloc_pos, ctx_pos = -1;
|
||||
Py_ssize_t ret = 0;
|
||||
int jump;
|
||||
unsigned int sigcount=0;
|
||||
unsigned int sigcount = state->sigcount;
|
||||
|
||||
SRE(match_context)* ctx;
|
||||
SRE(match_context)* nextctx;
|
||||
|
|
@ -1567,8 +1567,10 @@ exit:
|
|||
ctx_pos = ctx->last_ctx_pos;
|
||||
jump = ctx->jump;
|
||||
DATA_POP_DISCARD(ctx);
|
||||
if (ctx_pos == -1)
|
||||
if (ctx_pos == -1) {
|
||||
state->sigcount = sigcount;
|
||||
return ret;
|
||||
}
|
||||
DATA_LOOKUP_AT(SRE(match_context), ctx, ctx_pos);
|
||||
|
||||
switch (jump) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue