gh-123465: Allow Py_RELATIVE_OFFSET for __*offset__ members (GH-123474)

This commit is contained in:
Petr Viktorin 2024-09-05 14:14:05 +02:00 committed by GitHub
parent ce9f84a47b
commit 16be8db6be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 422 additions and 74 deletions

View file

@ -485,7 +485,8 @@ Accessing attributes of extension types
``PyMemberDef`` may contain a definition for the special member
``"__vectorcalloffset__"``, corresponding to
:c:member:`~PyTypeObject.tp_vectorcall_offset` in type objects.
These must be defined with ``Py_T_PYSSIZET`` and ``Py_READONLY``, for example::
This member must be defined with ``Py_T_PYSSIZET``, and either
``Py_READONLY`` or ``Py_READONLY | Py_RELATIVE_OFFSET``. For example::
static PyMemberDef spam_type_members[] = {
{"__vectorcalloffset__", Py_T_PYSSIZET,
@ -506,6 +507,12 @@ Accessing attributes of extension types
``PyMemberDef`` is always available.
Previously, it required including ``"structmember.h"``.
.. versionchanged:: 3.14
:c:macro:`Py_RELATIVE_OFFSET` is now allowed for
``"__vectorcalloffset__"``, ``"__dictoffset__"`` and
``"__weaklistoffset__"``.
.. c:function:: PyObject* PyMember_GetOne(const char *obj_addr, struct PyMemberDef *m)
Get an attribute belonging to the object at address *obj_addr*. The