mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-106919: Use role :c:macro: for referencing the C "constants" (GH-106920) (GH-106951)
(cherry picked from commit fcc816dbff
)
This commit is contained in:
parent
807afdac41
commit
ac9aa8a369
46 changed files with 309 additions and 291 deletions
|
@ -335,7 +335,7 @@ When using only ``METH_VARARGS``, the function should expect the Python-level
|
|||
parameters to be passed in as a tuple acceptable for parsing via
|
||||
:c:func:`PyArg_ParseTuple`; more information on this function is provided below.
|
||||
|
||||
The :const:`METH_KEYWORDS` bit may be set in the third field if keyword
|
||||
The :c:macro:`METH_KEYWORDS` bit may be set in the third field if keyword
|
||||
arguments should be passed to the function. In this case, the C function should
|
||||
accept a third ``PyObject *`` parameter which will be a dictionary of keywords.
|
||||
Use :c:func:`PyArg_ParseTupleAndKeywords` to parse the arguments to such a
|
||||
|
@ -527,7 +527,7 @@ be part of a module definition::
|
|||
}
|
||||
|
||||
This function must be registered with the interpreter using the
|
||||
:const:`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The
|
||||
:c:macro:`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The
|
||||
:c:func:`PyArg_ParseTuple` function and its arguments are documented in section
|
||||
:ref:`parsetuple`.
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ only used for variable-sized objects and should otherwise be zero.
|
|||
base type will be :class:`object`, or else you will be adding data members to
|
||||
your base type, and therefore increasing its size.
|
||||
|
||||
We set the class flags to :const:`Py_TPFLAGS_DEFAULT`. ::
|
||||
We set the class flags to :c:macro:`Py_TPFLAGS_DEFAULT`. ::
|
||||
|
||||
.tp_flags = Py_TPFLAGS_DEFAULT,
|
||||
|
||||
|
@ -498,7 +498,7 @@ definitions::
|
|||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
(note that we used the :const:`METH_NOARGS` flag to indicate that the method
|
||||
(note that we used the :c:macro:`METH_NOARGS` flag to indicate that the method
|
||||
is expecting no arguments other than *self*)
|
||||
|
||||
and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::
|
||||
|
@ -508,7 +508,7 @@ and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::
|
|||
Finally, we'll make our type usable as a base class for subclassing. We've
|
||||
written our methods carefully so far so that they don't make any assumptions
|
||||
about the type of the object being created or used, so all we need to do is
|
||||
to add the :const:`Py_TPFLAGS_BASETYPE` to our class flag definition::
|
||||
to add the :c:macro:`Py_TPFLAGS_BASETYPE` to our class flag definition::
|
||||
|
||||
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
||||
|
||||
|
@ -774,7 +774,7 @@ and ``Custom_clear``::
|
|||
Py_TYPE(self)->tp_free((PyObject *) self);
|
||||
}
|
||||
|
||||
Finally, we add the :const:`Py_TPFLAGS_HAVE_GC` flag to the class flags::
|
||||
Finally, we add the :c:macro:`Py_TPFLAGS_HAVE_GC` flag to the class flags::
|
||||
|
||||
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue