aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2024-02-15 02:00:50 +0900
committerGitHub <noreply@github.com>2024-02-15 02:00:50 +0900
commita2d4281415e67c62f91363376db97eb66a9fb716 (patch)
treea70679c72f7c89af35614c6e1258c4507bd741a8 /Python/generated_cases.c.h
parent4b2d1786ccf913bc80ff571c32b196be1543ca54 (diff)
downloadcpython-a2d4281415e67c62f91363376db97eb66a9fb716.tar.gz
cpython-a2d4281415e67c62f91363376db97eb66a9fb716.zip
gh-112087: Make __sizeof__ and listiter_{len, next} to be threadsafe (gh-114843)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index a49223e4db5..177bc327454 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -2541,11 +2541,14 @@
assert(Py_TYPE(iter) == &PyListIter_Type);
STAT_INC(FOR_ITER, hit);
PyListObject *seq = it->it_seq;
- if (seq == NULL || it->it_index >= PyList_GET_SIZE(seq)) {
+ if ((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)) {
+ it->it_index = -1;
+ #ifndef Py_GIL_DISABLED
if (seq != NULL) {
it->it_seq = NULL;
Py_DECREF(seq);
}
+ #endif
Py_DECREF(iter);
STACK_SHRINK(1);
/* Jump forward oparg, then skip following END_FOR and POP_TOP instructions */