FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-135906: Use _PyObject_CAST in internal CPython headers by clin1234 · Pull Request #135892 · python/cpython · GitHub

/ cpython Public

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

Merged
ZeroIntensity merged 7 commits into
python:mainfrom
clin1234:cpp_trivial
Jul 7, 2025
Merged

gh-135906: Use _PyObject_CAST in internal CPython headers#135892
ZeroIntensity merged 7 commits into
python:mainfrom
clin1234:cpp_trivial

Conversation

clin1234 commented Jun 24, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

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

clin1234 requested a review from Fidget-Spinner as a code owner June 24, 2025 13:32

python-cla-bot Bot commented Jun 24, 2025
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

bedevere-app Bot commented Jun 24, 2025

Copy link
Copy Markdown

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 commented Jun 24, 2025

Copy link
Copy Markdown
Member

Please open an issue in this tracker.

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please also add a blurb entry, per the bot.

Comment thread Include/internal/pycore_object.h Outdated
ZeroIntensity added the build The build process and cross-build label Jun 24, 2025
clin1234 changed the title Use _Py_STATIC_CAST in internal CPython headers Use _PyObject_CAST in internal CPython headers Jun 25, 2025
clin1234 changed the title Use _PyObject_CAST in internal CPython headers gh-135906: Use _PyObject_CAST in internal CPython headers Jun 25, 2025

auvipy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

looks good

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 commented Jun 26, 2025
edited
Loading

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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 commented Jun 27, 2025
edited
Loading

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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

Comment thread Include/internal/pycore_stackref.h Outdated

vstinner commented Jul 3, 2025

Copy link
Copy Markdown
Member

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>

Copy link
Copy Markdown
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 commented Jul 3, 2025

Copy link
Copy Markdown
Member

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 commented Jul 3, 2025

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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

vstinner commented Jul 3, 2025

Copy link
Copy Markdown
Member

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.

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This change on its own looks good to me. We'll figure out testing this in #136247.

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

ZeroIntensity merged commit fe187fa into python:main Jul 7, 2025

Copy link
Copy Markdown

Thanks @clin1234 for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 7, 2025
…35892)

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------
(cherry picked from commit fe187fa)

Co-authored-by: Charlie Lin <tuug@gmx.us>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>

bedevere-app Bot commented Jul 7, 2025

Copy link
Copy Markdown

GH-136392 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 7, 2025
clin1234 deleted the cpp_trivial branch July 7, 2025 17:03
ZeroIntensity added a commit that referenced this pull request Jul 7, 2025
GH-136392)

gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892)

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------
(cherry picked from commit fe187fa)

Co-authored-by: Charlie Lin <tuug@gmx.us>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
…135892)

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
…135892)

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
picnixz pushed a commit to picnixz/cpython that referenced this pull request Jul 13, 2025
…135892)

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…135892)

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
…135892)

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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


Back | FazBrowse Home | New Git URL