gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h#99014
gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h#99014encukou merged 14 commits into
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 |
Sorry, something went wrong.
And by the same token, |
Sorry, something went wrong.
|
And here are tests. |
Sorry, something went wrong.
erlend-aasland
left a comment
There was a problem hiding this comment.
Looks good. I did some nitpicking.
Sorry, something went wrong.
|
Thank you! I did the changes, and will merge once everything is green. |
Sorry, something went wrong.
|
Nice work! |
Sorry, something went wrong.
|
Isn't it strange that the only public constant for object has an |
Sorry, something went wrong.
|
I agree that
By the way, how was
|
Sorry, something went wrong.
|
Both T_NONE was introduced in 50e9fb9. I have not found a single case of its use. |
Sorry, something went wrong.
Maybe it's not worth it to add |
Sorry, something went wrong.
|
Sorry, something went wrong.
The
structmember.hheader 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_SetOnePY_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_RESTRICTEDwhich does nothing.RESTRICTEDandREAD_RESTRICTED, equivalents ofPY_AUDIT_READ.<stddef.h>is not included fromPython.h.It should be included manually when using
offsetof().The
PY_T_*,PY_READONLYandPY_AUDIT_READmacros 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_membersare already listed.There is discussion on the issue to rename
T_PYSSIZETtoPY_T_SSIZEor 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 abalkin@users.noreply.github.com
Co-Authored-By: Matthias Braun MatzeB@users.noreply.github.com