summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-07-08 17:09:54 (GMT)
committerGitHub <noreply@github.com>2024-07-08 17:09:54 (GMT)
commit2f8919ee3c152d6249a0a0dc14c86c0547bfe4b6 (patch)
treef326657095036be41e5a7875769427faff57161a /Python/bytecodes.c
parentbccfd8a53f0c96480526887762ed4f833cd957cb (diff)
downloadcpython-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/bytecodes.c')
-rw-r--r--Python/bytecodes.c5
1 files changed, 4 insertions, 1 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)) {