Skip to content

PEP 788: Address feedback from the C API WG #4521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ZeroIntensity
Copy link
Member

@ZeroIntensity ZeroIntensity commented Aug 3, 2025

  • Change is either:
    • To a Draft PEP
    • To an Accepted or Final PEP, with Steering Council approval
    • To fix an editorial issue (markup, typo, link, header, etc)
  • PR title prefixed with PEP number (e.g. PEP 123: Summary of changes)

📚 Documentation preview 📚: https://pep-previews--4521.org.readthedocs.build/pep-0788/

@ZeroIntensity
Copy link
Member Author

@AA-Turner Did I break something here, or is readthedocs acting up? Sphinx is building without warnings for me locally.

@AA-Turner
Copy link
Member

WARNING: failed to reach any of the inventories with the following issues:
62	intersphinx inventory 'https://packaging.python.org/en/latest//objects.inv' not fetchable due to <class 'requests.exceptions.HTTPError'>: 530 Server Error:  for url: https://packaging.python.org/en/latest//objects.inv

From Line 60; the lack of packaging cross reference targets is the cause of the failure.

A

@hugovk
Copy link
Member

hugovk commented Aug 4, 2025

I restarted it and it passed this time:

https://app.readthedocs.org/projects/pep-previews/builds/29079852/

The interpreter will wait until a strong reference has been released
before shutting down.

This type is guaranteed to be pointer-sized.

.. c:function:: int PyInterpreterRef_Get(PyInterpreterRef *ref)
.. c:function:: PyInterpreterRef PyInterpreterRef_FromCurrent(void)
Copy link
Member

Choose a reason for hiding this comment

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

I prefer PyInterpreterRef_Get() and PyInterpreterWeakRef_Get() which are consistent with existing PyThreadState_Get() and PyInterpreterState_Get().

Copy link
Member Author

Choose a reason for hiding this comment

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

Me too, but please bring this up on the C API WG discussion. I'm just following suggestions from Steve and Petr here.

to a strong reference to the interpreter, and returns ``-1``
with an exception set on failure.
On success, this function returns a strong reference to the current
interpreter, and returns ``0`` with an exception set on failure.
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to "enforce error checking" by returning -1 on error:

        PyInterpreterRef ref;
        if (PyInterpreterRef_Get(&ref) < 0) {
            return NULL;
        }

But if others prefer checking if ref is zero, I would be fine with that API as well.

…rpreterRef.

Per discussion on DPO. The idea is that this is a general
runtime/lifecycle API, not an operation executing on an interpreter
reference.
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