From 1b96cc1c42e161d923f88eefa1112eef9918bca2 Mon Sep 17 00:00:00 2001 From: da-woods Date: Thu, 8 May 2025 18:34:01 +0100 Subject: [PATCH 1/2] Make it clear Py_VISIT is a macro in the docs It has the hidden return inside it, so to me the `void` return type is a little misleading because it implies that it behaves like a C function. --- Doc/c-api/gcsupport.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst index d1f0982b818931..da84e7172a8c11 100644 --- a/Doc/c-api/gcsupport.rst +++ b/Doc/c-api/gcsupport.rst @@ -180,7 +180,7 @@ provided. In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` must name its arguments exactly *visit* and *arg*: -.. c:function:: void Py_VISIT(PyObject *o) +.. c:macro:: Py_VISIT(PyObject *o) If *o* is not ``NULL``, call the *visit* callback, with arguments *o* and *arg*. If *visit* returns a non-zero value, then return it. From 1300400a0b5685fc7082e0e2398072ba8b969586 Mon Sep 17 00:00:00 2001 From: da-woods Date: Sat, 10 May 2025 08:12:18 +0100 Subject: [PATCH 2/2] avoid giving arg types for macros --- Doc/c-api/gcsupport.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst index da84e7172a8c11..3e23605778f05a 100644 --- a/Doc/c-api/gcsupport.rst +++ b/Doc/c-api/gcsupport.rst @@ -180,9 +180,9 @@ provided. In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` must name its arguments exactly *visit* and *arg*: -.. c:macro:: Py_VISIT(PyObject *o) +.. c:macro:: Py_VISIT(o) - If *o* is not ``NULL``, call the *visit* callback, with arguments *o* + If the :c:expr:`PyObject *` *o* is not ``NULL``, call the *visit* callback, with arguments *o* and *arg*. If *visit* returns a non-zero value, then return it. Using this macro, :c:member:`~PyTypeObject.tp_traverse` handlers look like::