Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-129139: Fix __setstate__ on exhausted list iterators in free-threaded build#146269

Open
ytang928 wants to merge 2 commits intopython:mainfrom
ytang928:gh-129139-fix-listiter-setstate
Open

gh-129139: Fix __setstate__ on exhausted list iterators in free-threaded build#146269
ytang928 wants to merge 2 commits intopython:mainfrom
ytang928:gh-129139-fix-listiter-setstate

Conversation

@ytang928
Copy link

In free-threaded builds, exhausted list iterators signal exhaustion by
settingit_index to-1 without clearingit_seq toNULL (to avoid
expensive atomic refcount operations on the hot path). The existing
it_seq != NULL guard inlistiter_setstate andlistreviter_setstate
allowed__setstate__ to revive an exhausted iterator by resetting
it_index to a valid value.

This adds anit_index >= 0 check so that__setstate__ is a no-op on
exhausted iterators, consistent with GIL-enabled build behavior.

The same fix is applied to bothlistiter_setstate andlistreviter_setstate,
which share the same pattern.

…-threaded buildIn free-threaded builds, exhausted list iterators signal exhaustion bysetting it_index to -1 without clearing it_seq to NULL. The existingit_seq != NULL guard in listiter_setstate and listreviter_setstateallowed __setstate__ to revive an exhausted iterator by resettingit_index to a valid value.Add an it_index >= 0 check so that __setstate__ is a no-op onexhausted iterators, consistent with GIL-enabled build behavior.
@python-cla-bot
Copy link

python-cla-botbot commentedMar 22, 2026
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@ytang928

[8]ページ先頭

©2009-2026 Movatter.jp