diff options
author | Mark Shannon <mark@hotpy.org> | 2024-07-08 13:20:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 13:20:13 (GMT) |
commit | 8ad6067bd4556afddc86004f8e350aa672fda217 (patch) | |
tree | 15a15f25d7d11db22399be2a26ec6e2ae889976c /Python | |
parent | d69529d31ccd1510843cfac1ab53bb8cb027541f (diff) | |
download | cpython-8ad6067bd4556afddc86004f8e350aa672fda217.zip cpython-8ad6067bd4556afddc86004f8e350aa672fda217.tar.gz cpython-8ad6067bd4556afddc86004f8e350aa672fda217.tar.bz2 |
GH-121012: Set index to -1 when list iterators become exhausted in tier 2 (GH-121483)
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 76587a4..84241c6 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2967,7 +2967,10 @@ dummy_func( assert(Py_TYPE(iter_o) == &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 3b99946..8f6bc75 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -3055,8 +3055,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; } |