summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorJim Fulton <jim@zope.com>2004-07-14 19:08:17 (GMT)
committerJim Fulton <jim@zope.com>2004-07-14 19:08:17 (GMT)
commitaa6389e13be460cce1f16f2a525ba8754737d30b (patch)
tree719b5d9c9331896054b9a4f09e5d2e95e086f898 /Doc
parent8c5aeaa2770c958414c0785229a5e038ed97a234 (diff)
downloadcpython-aa6389e13be460cce1f16f2a525ba8754737d30b.zip
cpython-aa6389e13be460cce1f16f2a525ba8754737d30b.tar.gz
cpython-aa6389e13be460cce1f16f2a525ba8754737d30b.tar.bz2
Documented the new Py_VISIT macro to simplify implementation of
tp_traverse handlers. (Tim made me do it. ;)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/api/newtypes.tex23
1 files changed, 23 insertions, 0 deletions
diff --git a/Doc/api/newtypes.tex b/Doc/api/newtypes.tex
index 036664e..2b58cd9 100644
--- a/Doc/api/newtypes.tex
+++ b/Doc/api/newtypes.tex
@@ -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.