Skip to content

gh-149101: Implement PEP 788#149116

Merged
ZeroIntensity merged 93 commits intopython:mainfrom
ZeroIntensity:pep-788
May 6, 2026
Merged

gh-149101: Implement PEP 788#149116
ZeroIntensity merged 93 commits intopython:mainfrom
ZeroIntensity:pep-788

Conversation

@ZeroIntensity
Copy link
Copy Markdown
Member

@ZeroIntensity ZeroIntensity commented Apr 28, 2026

Hugo has graciously given me permission to backport this if we don't make the May 5th deadline, but let's try to get this done in time!

I will write a full tutorial and migration guide once this is merged; I want to first make sure that this lands before the beta freeze.

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Apr 28, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32572982 | 📁 Comparing 53fa94b against main (40dc61a)

  🔍 Preview build  

76 files changed · + 1 added · ± 75 modified

+ Added

± Modified

Copy link
Copy Markdown
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these!

I'll send notes for Doc/ now; code review coming up.

Comment thread Doc/c-api/interp-lifecycle.rst Outdated
Comment thread Doc/c-api/interp-lifecycle.rst Outdated
Comment thread Doc/c-api/interp-lifecycle.rst Outdated
Comment thread Doc/c-api/interp-lifecycle.rst
Comment thread Doc/c-api/interp-lifecycle.rst Outdated
Comment thread Doc/c-api/threads.rst Outdated
Comment thread Doc/c-api/threads.rst Outdated
Comment thread Doc/c-api/threads.rst Outdated
Comment thread Doc/c-api/threads.rst Outdated
Comment thread Doc/whatsnew/3.15.rst Outdated
ZeroIntensity and others added 5 commits April 29, 2026 08:24
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
@ZeroIntensity ZeroIntensity added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 29, 2026
@bedevere-bot
Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit bc78c10 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F149116%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 29, 2026
@encukou
Copy link
Copy Markdown
Member

encukou commented Apr 30, 2026

for buildbots: The RHEL8 failures aren't relevant. Refleaks are worrying though.

@encukou
Copy link
Copy Markdown
Member

encukou commented Apr 30, 2026

Refleaks are worrying though.

Never mind; main currently leaks (#149179).

@ZeroIntensity ZeroIntensity added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 6, 2026
@bedevere-bot
Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit a34dbc6 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F149116%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 6, 2026
@colesbury
Copy link
Copy Markdown
Contributor

This looks good to me. The only remaining issues I see are minor. GitHub is kind of broken so here are my comments:

  • Some things found by Claude: https://gist.github.com/colesbury/e3ecafad30bb291d205c7be88c7fe7d4 (same as I messaged Peter in Discord)
  • In make_pre_finalization_calls, the atomic compare exchange on finalization_guards should happen before HEAD_UNLOCK(interp->runtime). In other words, we should do both the checks and state transition under the same locks.
  • We don't need both NO_TSTATE_SENTINEL and DETACHED_TSTATE_SENTINEL. You can just keep one or the other.

The comment about tstate->ensure.owned_guard = NULL (" This is usually done by PyThreadState_Clear()...") is confusing to me. The owned_guard = NULL in PyThreadState_Clear is both useless and not a concern of PyThreadState_Clear. These fields are managed by Ensure/Release, not PyThreadState_New/Clear/Delete and we are not clearing or touching any of the other ensure fields. I'd remove that line from PyThreadState_Clear and write the relevant part of PyThreadState_Release as:

    if (tstate->ensure.delete_on_release) {
        ++tstate->ensure.counter;
        PyThreadState_Clear(tstate);
        --tstate->ensure.counter;
    }
    else if (owned_guard != NULL) {
        tstate->ensure.owned_guard = NULL;
    }

@ZeroIntensity ZeroIntensity merged commit 2b7c28a into python:main May 6, 2026
82 checks passed
@ZeroIntensity ZeroIntensity deleted the pep-788 branch May 6, 2026 21:39
@ZeroIntensity
Copy link
Copy Markdown
Member Author

Thanks for the reviews, both of you! Sorry again about the rushing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants