-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-99574: Add Py_SETREF() to the limited C API #99575
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
Conversation
This adds much more than Py_SETREF() and Py_XSETREF(). |
In terms of API, only Py_SETREF() and Py_XSETREF() are added to the limited C API. But while I was updating Misc/stable_abi.toml, I noticed that many macros were already part of the limited C API but not documented as being part of it. |
I updated the commit message (and PR description) to mention that the change also adds macros missing in Misc/stable_abi.toml but already part of the limited C API. |
|
I don't understand that. Is there a definition of what is the limited C API in this case? What is Py_LIMITED_API if it doesn't define the limited C API? |
|
Misc/stable_abi.toml
Outdated
[macro.Py_REFCNT] | ||
added = '3.2' | ||
[macro.Py_SET_REFCNT] | ||
added = '3.9' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't think we want to add these.
Ok, now I'm confused. Py_LIMITED_API is documented as:
When I define this macro, the Py_TYPE() macro is available. But Py_TYPE() is not part of Misc/stable_abi.toml. So something is wrong: either Py_TYPE() should be added to Misc/stable_abi.toml, to Py_TYPE() must not defined if Py_LIMITED_API is defined. For example module
This code is even required to define heap types:
This is just one example. I'm trying to understand what is the "limited C API" "according to you" :-) (Sadly, it seems like different people have a different definition.) |
PEP 384 explicitly gives access to object type and reference count, by giving access to IMO using an abstraction, Py_REFCNT() and Py_SET_REFCNT(), is better than giving access to the structure members. IMO these macros are already part of the limited C API, since they are accessible with the Py_LIMITED_API macro is defined, but it seems like we have a different view on what is the limited C API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
That's the intention. But, there are always bugs -- wrong What makes
In this case, it looks like
See
I see as |
I rewrote this PR to restrict it to Py_SETREF() and Py_XSETREF(). I added I now agree that adding other macros to Misc/stable_abi.toml should be discussed in separated issues/PRs. |
Once this PR will be merged, I will open separated issues/PRs for other discussed macros:
|
PR rebased on main to fix a conflict on Misc/stable_abi.toml. |
Add Py_SETREF() and Py_XSETREF() macros to the limited C API.
✅ Deploy Preview for python-cpython-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
I fixed a type punning bug which caused Python to be miscompiled: commit b11a384. I rebased this PR on top of it. |
Add Py_SETREF() and Py_XSETREF() macros to the limited C API.