list iterator `__setstate__()` differs for exhausted iterator GIL vs. non-GIL
Open
Nobody has claimed this yet.
interpreter-core
topic-free-threading
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Or is this too pedantic?
GIL enabled:
$ ./python
Python 3.14.0a4+ (heads/main:f3980af38b, Jan 21 2025, 11:34:12) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> it = iter([1]); list(it)
[1]
>>> it.__setstate__(0); list(it)
[]
GIL disabled:
$ ./python
Python 3.14.0a4+ experimental free-threading build (heads/main:f3980af38b, Jan 21 2025, 11:31:38) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> it = iter([1]); list(it)
[1]
>>> it.__setstate__(0); list(it)
[1]
v3.14, current main, its a one line fix.
Linked PRs
- gh-146269
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the listed iterator behavior in both GIL-enabled and free-threading Python builds, then trace the list iterator setstate() entry point. Done means exhausted iterators behave consistently after setstate(0) in both builds; the issue mentions linked PR gh-146269.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100