gh-135906: Use _PyObject_CAST in internal CPython headers by clin1234 · Pull Request #135892 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

gh-135906: Use _PyObject_CAST in internal CPython headers #135892

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 7 commits into
base: main
Choose a base branch
from

Conversation

clin1234
Copy link

@clin1234 clin1234 commented Jun 24, 2025

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet against CPython 3.14.0b3 free-threaded. Resolves #135906

@clin1234 clin1234 requested a review from Fidget-Spinner as a code owner June 24, 2025 13:32
@python-cla-bot
Copy link

python-cla-bot bot commented Jun 24, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jun 24, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@picnixz
Copy link
Member

picnixz commented Jun 24, 2025

Please open an issue in this tracker.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Please also add a blurb entry, per the bot.

@ZeroIntensity ZeroIntensity added the build The build process and cross-build label Jun 24, 2025
@clin1234 clin1234 changed the title Use _Py_STATIC_CAST in internal CPython headers Use _PyObject_CAST in internal CPython headers Jun 25, 2025
@clin1234 clin1234 changed the title Use _PyObject_CAST in internal CPython headers gh-135906: Use _PyObject_CAST in internal CPython headers Jun 25, 2025
Copy link

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

looks good

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

I see some similar issues elsewhere:

PyObject *op = _PyFreeList_PopNoStats(fl);

PyObject *obj = FT_ATOMIC_LOAD_PTR(ref->wr_object);

PyObject *obj = FT_ATOMIC_LOAD_PTR(ref->wr_object);

Theoretically, we could test for this by including internal headers in test_cppext, but I haven't decided whether I think that's a good idea yet. I'm worried that we're going to be encouraging people to use the private API. Which APIs does Greenlet need?

…CWq.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@clin1234
Copy link
Author

clin1234 commented Jun 26, 2025

I see some similar issues elsewhere:

PyObject *op = _PyFreeList_PopNoStats(fl);

PyObject *obj = FT_ATOMIC_LOAD_PTR(ref->wr_object);

PyObject *obj = FT_ATOMIC_LOAD_PTR(ref->wr_object);

Theoretically, we could test for this by including internal headers in test_cppext, but I haven't decided whether I think that's a good idea yet. I'm worried that we're going to be encouraging people to use the private API. Which APIs does Greenlet need?

This:

https://github.com/python-greenlet/greenlet/blob/b24e39c992e1758032bd913bf7c03d239c29480b/src/greenlet/TGreenlet.hpp#L30-L37

@ZeroIntensity
Copy link
Member

Ok. For 3.15, please open an issue requesting that those private APIs be exposed as unstable APIs.

@Fidget-Spinner
Copy link
Member

Ok. For 3.15, please open an issue requesting that those private APIs be exposed as unstable APIs.

They don't need to open a new issue. This is a known issue with Cython reporting it as well #130931

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented Jun 27, 2025

I would be happy to merge this (I won't block it). However, we should have some way to make sure we don't regress. pycore_interpframe.h seems to be used by greenlet and Cython which makes it a big enough use case.

@ZeroIntensity
Copy link
Member

I think including pycore_interpframe.h (or pycore_interp_structs.h) in test_cppext would work as a good regression test.

@vstinner
Copy link
Member

vstinner commented Jul 3, 2025

I think including pycore_interpframe.h (or pycore_interp_structs.h) in test_cppext would work as a good regression test.

I wrote test_cppext to test the public C API (headers). Please don't include the internal C API in test_cppext, or add new tests.

Co-authored-by: Victor Stinner <vstinner@python.org>
@ZeroIntensity
Copy link
Member

Hm, why not? Wouldn't it be easier if we were able to catch regressions immediately instead of Cython or Greenlet complaining to us later?

@vstinner
Copy link
Member

vstinner commented Jul 3, 2025

I mean that I would prefer to leave existing test_cppext unchanged. But you can add new tests on the internal C API if you want.

@vstinner
Copy link
Member

vstinner commented Jul 3, 2025

I wrote #136247 to test the internal C API in test_cext.

So far, I failed to test the internal C API with C++, I get many compiler errors from mimalloc headers and I'm not sure how to handle them.

@ZeroIntensity
Copy link
Member

I think we can ignore mimalloc. Nobody--even Cython--is using that with the internal headers.

@vstinner
Copy link
Member

vstinner commented Jul 3, 2025

I think we can ignore mimalloc. Nobody--even Cython--is using that with the internal headers.

mimalloc is included indirectly by many internal headers such as pycore_interp.h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review build The build process and cross-build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use _PyObject_CAST in internal headers
6 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.