mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Documented the new Py_VISIT macro to simplify implementation of
tp_traverse handlers. (Tim made me do it. ;)
This commit is contained in:
parent
8c5aeaa277
commit
aa6389e13b
2 changed files with 33 additions and 0 deletions
|
|
@ -1663,6 +1663,29 @@ The \member{tp_traverse} handler must have the following type:
|
|||
that value should be returned immediately.
|
||||
\end{ctypedesc}
|
||||
|
||||
To simplify writing \member{tp_traverse} handlers, a
|
||||
\cfunction{Py_VISIT()} is provided:
|
||||
|
||||
\begin{cfuncdesc}{void}{Py_VISIT}{PyObject *o}
|
||||
Call the \var{visit} for \var{o} with \var{arg}. If \var{visit}
|
||||
returns a non-zero value, then return it. Using this macro,
|
||||
\member{tp_traverse} handlers look like:
|
||||
|
||||
|
||||
\begin{verbatim}
|
||||
static int
|
||||
my_traverse(Noddy *self, visitproc visit, void *arg)
|
||||
{
|
||||
Py_VISIT(self->foo);
|
||||
Py_VISIT(self->bar);
|
||||
return 0;
|
||||
}
|
||||
\end{verbatim}
|
||||
|
||||
\versionadded{2.4}
|
||||
\end{cfuncdesc}
|
||||
|
||||
|
||||
The \member{tp_clear} handler must be of the \ctype{inquiry} type, or
|
||||
\NULL{} if the object is immutable.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue