Commit 71a1232
committed
gh-129139: Fix __setstate__ on exhausted list iterators in free-threaded build
In free-threaded builds, exhausted list iterators signal exhaustion by
setting it_index to -1 without clearing it_seq to NULL. The existing
it_seq != NULL guard in listiter_setstate and listreviter_setstate
allowed __setstate__ to revive an exhausted iterator by resetting
it_index to a valid value.
Add an it_index >= 0 check so that __setstate__ is a no-op on
exhausted iterators, consistent with GIL-enabled build behavior.1 parent 83360b5 commit 71a1232
File tree
3 files changed
+17
-2
lines changed- Lib/test
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
3 files changed
+17
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
216 | 230 | | |
217 | 231 | | |
218 | 232 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4108 | 4108 | | |
4109 | 4109 | | |
4110 | 4110 | | |
4111 | | - | |
| 4111 | + | |
4112 | 4112 | | |
4113 | 4113 | | |
4114 | 4114 | | |
| |||
4260 | 4260 | | |
4261 | 4261 | | |
4262 | 4262 | | |
4263 | | - | |
| 4263 | + | |
4264 | 4264 | | |
4265 | 4265 | | |
4266 | 4266 | | |
| |||
0 commit comments