diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-07-08 17:09:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 17:09:54 (GMT) |
commit | 2f8919ee3c152d6249a0a0dc14c86c0547bfe4b6 (patch) | |
tree | f326657095036be41e5a7875769427faff57161a /Python | |
parent | bccfd8a53f0c96480526887762ed4f833cd957cb (diff) | |
download | cpython-2f8919ee3c152d6249a0a0dc14c86c0547bfe4b6.zip cpython-2f8919ee3c152d6249a0a0dc14c86c0547bfe4b6.tar.gz cpython-2f8919ee3c152d6249a0a0dc14c86c0547bfe4b6.tar.bz2 |
[3.13] GH-121012: Set index to -1 when list iterators become exhausted in tier 2 (GH-121483) (GH-121494)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bytecodes.c | 5 | ||||
-rw-r--r-- | Python/executor_cases.c.h | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 0dc60bb..a6e9a73 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2695,7 +2695,10 @@ dummy_func( assert(Py_TYPE(iter) == &PyListIter_Type); PyListObject *seq = it->it_seq; EXIT_IF(seq == NULL); - EXIT_IF((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)); + if ((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)) { + it->it_index = -1; + EXIT_IF(1); + } } op(_ITER_NEXT_LIST, (iter -- iter, next)) { diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 4e0f73f..8080d20 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -2675,8 +2675,11 @@ JUMP_TO_JUMP_TARGET(); } if ((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)) { - UOP_STAT_INC(uopcode, miss); - JUMP_TO_JUMP_TARGET(); + it->it_index = -1; + if (1) { + UOP_STAT_INC(uopcode, miss); + JUMP_TO_JUMP_TARGET(); + } } break; } |