-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h #99014
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
Old names are kept as aliases.
These docs were ripe for an overhaul, so I did one when touching the code.
Today I noticed the style guide says macros should have the |
And by the same token, |
And here are tests. |
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.
Looks good. I did some nitpicking.
Thank you! I did the changes, and will merge once everything is green. |
Nice work! |
Isn't it strange that the only public constant for object has an |
I agree that
By the way, how was
|
Both T_NONE was introduced in 50e9fb9. I have not found a single case of its use. |
Maybe it's not worth it to add |
|
The
structmember.h
header is deprecated, though it continues to be available and there are no plans to remove it. There are no deprecation warnings. Old code can stay unchanged (unless the extra include and non-namespaced macros bother you greatly). Specifically, no uses in CPython are updated -- that would just be unnecessary churn.The header's contents are now available just by including
Python.h
, with aPY_
prefix added if it was missing:PyMemberDef
,PyMember_GetOne
,PyMember_SetOne
PY_T_INT
,PY_T_DOUBLE
, etc. (previouslyT_INT
,T_DOUBLE
, etc.)PY_READONLY
(previouslyREADONLY
) andPY_AUDIT_READ
(name unchanged)Several items are not exposed from
Python.h
:T_OBJECT
(usePY_T_OBJECT_EX
)T_NONE
(previously undocumented, and pretty quirky)WRITE_RESTRICTED
which does nothing.RESTRICTED
andREAD_RESTRICTED
, equivalents ofPY_AUDIT_READ
.<stddef.h>
is not included fromPython.h
.It should be included manually when using
offsetof()
.The
PY_T_*
,PY_READONLY
andPY_AUDIT_READ
macros are added to the stable API manifest. This is just a clerical change, really -- Stable ABI extensions in the wild usestructmember.h
, andPyMemberDef
&Py_tp_members
are already listed.There is discussion on the issue to rename
T_PYSSIZET
toPY_T_SSIZE
or similar. I chose not to do that -- users will probably copy/paste that with any spelling, and not renaming it makes migration docs simpler.Co-Authored-By: Alexander Belopolsky [email protected]
Co-Authored-By: Matthias Braun [email protected]