Skip to content

Commit 4695ec1

Browse files
authored
pythongh-138189: Link references to type slots (pythonGH-141410)
Link references to type slots
1 parent a52c39e commit 4695ec1

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

Doc/c-api/structures.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,14 +698,12 @@ The following flags can be used with :c:member:`PyMemberDef.flags`:
698698
entry indicates an offset from the subclass-specific data, rather than
699699
from ``PyObject``.
700700
701-
Can only be used as part of :c:member:`Py_tp_members <PyTypeObject.tp_members>`
701+
Can only be used as part of the :c:data:`Py_tp_members`
702702
:c:type:`slot <PyType_Slot>` when creating a class using negative
703703
:c:member:`~PyType_Spec.basicsize`.
704704
It is mandatory in that case.
705-
706-
This flag is only used in :c:type:`PyType_Slot`.
707-
When setting :c:member:`~PyTypeObject.tp_members` during
708-
class creation, Python clears it and sets
705+
When setting :c:member:`~PyTypeObject.tp_members` from the slot during
706+
class creation, Python clears the flag and sets
709707
:c:member:`PyMemberDef.offset` to the offset from the ``PyObject`` struct.
710708
711709
.. index::

Doc/c-api/type.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ The following functions and structs are used to create
383383
384384
The *bases* argument can be used to specify base classes; it can either
385385
be only one class or a tuple of classes.
386-
If *bases* is ``NULL``, the *Py_tp_bases* slot is used instead.
387-
If that also is ``NULL``, the *Py_tp_base* slot is used instead.
386+
If *bases* is ``NULL``, the :c:data:`Py_tp_bases` slot is used instead.
387+
If that also is ``NULL``, the :c:data:`Py_tp_base` slot is used instead.
388388
If that also is ``NULL``, the new type derives from :class:`object`.
389389
390390
The *module* argument can be used to record the module in which the new
@@ -590,9 +590,9 @@ The following functions and structs are used to create
590590
:c:type:`PyAsyncMethods` with an added ``Py_`` prefix.
591591
For example, use:
592592
593-
* ``Py_tp_dealloc`` to set :c:member:`PyTypeObject.tp_dealloc`
594-
* ``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`
595-
* ``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`
593+
* :c:data:`Py_tp_dealloc` to set :c:member:`PyTypeObject.tp_dealloc`
594+
* :c:data:`Py_nb_add` to set :c:member:`PyNumberMethods.nb_add`
595+
* :c:data:`Py_sq_length` to set :c:member:`PySequenceMethods.sq_length`
596596
597597
An additional slot is supported that does not correspond to a
598598
:c:type:`!PyTypeObject` struct field:
@@ -611,7 +611,7 @@ The following functions and structs are used to create
611611
612612
If it is not possible to switch to a ``MANAGED`` flag (for example,
613613
for vectorcall or to support Python older than 3.12), specify the
614-
offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
614+
offset in :c:data:`Py_tp_members`.
615615
See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
616616
for details.
617617
@@ -639,7 +639,7 @@ The following functions and structs are used to create
639639
640640
.. versionchanged:: 3.14
641641
The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
642-
using ``Py_tp_vectorcall``. See the field's documentation
642+
using :c:data:`Py_tp_vectorcall`. See the field's documentation
643643
for details.
644644
645645
.. c:member:: void *pfunc
@@ -649,7 +649,7 @@ The following functions and structs are used to create
649649
650650
*pfunc* values may not be ``NULL``, except for the following slots:
651651
652-
* ``Py_tp_doc``
652+
* :c:data:`Py_tp_doc`
653653
* :c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC`
654654
rather than ``NULL``)
655655

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
22732273
This field should be set to ``NULL`` and treated as read-only.
22742274
Python will fill it in when the type is :c:func:`initialized <PyType_Ready>`.
22752275

2276-
For dynamically created classes, the ``Py_tp_bases``
2276+
For dynamically created classes, the :c:data:`Py_tp_bases`
22772277
:c:type:`slot <PyType_Slot>` can be used instead of the *bases* argument
22782278
of :c:func:`PyType_FromSpecWithBases`.
22792279
The argument form is preferred.

Doc/howto/isolating-extensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ garbage collection protocol.
353353
That is, heap types should:
354354

355355
- Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag.
356-
- Define a traverse function using ``Py_tp_traverse``, which
356+
- Define a traverse function using :c:data:`Py_tp_traverse`, which
357357
visits the type (e.g. using ``Py_VISIT(Py_TYPE(self))``).
358358

359359
Please refer to the documentation of

0 commit comments

Comments
 (0)