From 50a0ce1da56e7cc9c19e0302ebb7b7e551f7658b Mon Sep 17 00:00:00 2001 From: CharlieZhao Date: Fri, 22 Apr 2022 10:00:55 +0800 Subject: [PATCH 1/4] gh-91755: Document Py_IncRef and Py_DecRef as C function. --- Doc/c-api/refcounting.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst index 391907c8c2976a..ea3b82a865a212 100644 --- a/Doc/c-api/refcounting.rst +++ b/Doc/c-api/refcounting.rst @@ -109,11 +109,17 @@ objects. It is a good idea to use this macro whenever decrementing the reference count of an object that might be traversed during garbage collection. +.. c:function:: Py_IncRef(PyObject *o) + + :c:func:`Py_IncRef` is a simply exported function version of :c:func:`Py_XINCREF`, + which provides conveniences for runtime dynamic embedding of Python. + + +.. c:function:: Py_DecRef(PyObject *o) + + :c:func:`Py_DecRef` is a simply exported function version of :c:func:`Py_XDECREF`, + which provides conveniences for runtime dynamic embedding of Python. -The following functions are for runtime dynamic embedding of Python: -``Py_IncRef(PyObject *o)``, ``Py_DecRef(PyObject *o)``. They are -simply exported function versions of :c:func:`Py_XINCREF` and -:c:func:`Py_XDECREF`, respectively. The following functions or macros are only for use within the interpreter core: :c:func:`_Py_Dealloc`, :c:func:`_Py_ForgetReference`, :c:func:`_Py_NewReference`, From 109d25fdee3e9d12c817907bfa215f161c410dec Mon Sep 17 00:00:00 2001 From: CharlieZhao Date: Fri, 22 Apr 2022 10:31:07 +0800 Subject: [PATCH 2/4] Add the return value. --- Doc/c-api/refcounting.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst index ea3b82a865a212..fed0d69c4e44a3 100644 --- a/Doc/c-api/refcounting.rst +++ b/Doc/c-api/refcounting.rst @@ -109,13 +109,13 @@ objects. It is a good idea to use this macro whenever decrementing the reference count of an object that might be traversed during garbage collection. -.. c:function:: Py_IncRef(PyObject *o) +.. c:function:: void Py_IncRef(PyObject *o) :c:func:`Py_IncRef` is a simply exported function version of :c:func:`Py_XINCREF`, which provides conveniences for runtime dynamic embedding of Python. -.. c:function:: Py_DecRef(PyObject *o) +.. c:function:: void Py_DecRef(PyObject *o) :c:func:`Py_DecRef` is a simply exported function version of :c:func:`Py_XDECREF`, which provides conveniences for runtime dynamic embedding of Python. From 99b116a0d9d781ad0257cea5aaf9579880d60715 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Wed, 18 May 2022 10:07:27 +0200 Subject: [PATCH 3/4] Update Doc/c-api/refcounting.rst Co-authored-by: Jelle Zijlstra --- Doc/c-api/refcounting.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst index fed0d69c4e44a3..1a812be35607f9 100644 --- a/Doc/c-api/refcounting.rst +++ b/Doc/c-api/refcounting.rst @@ -111,8 +111,8 @@ objects. .. c:function:: void Py_IncRef(PyObject *o) - :c:func:`Py_IncRef` is a simply exported function version of :c:func:`Py_XINCREF`, - which provides conveniences for runtime dynamic embedding of Python. + Increment the reference count for object *o*. A function version of :c:func:`Py_XINCREF`. + It can be used for runtime dynamic embedding of Python. .. c:function:: void Py_DecRef(PyObject *o) From 58734415ff392d88193f04f4a18cc6d916953bcf Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Wed, 18 May 2022 10:07:32 +0200 Subject: [PATCH 4/4] Update Doc/c-api/refcounting.rst Co-authored-by: Jelle Zijlstra --- Doc/c-api/refcounting.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst index 1a812be35607f9..738bd77e9ce42f 100644 --- a/Doc/c-api/refcounting.rst +++ b/Doc/c-api/refcounting.rst @@ -117,8 +117,8 @@ objects. .. c:function:: void Py_DecRef(PyObject *o) - :c:func:`Py_DecRef` is a simply exported function version of :c:func:`Py_XDECREF`, - which provides conveniences for runtime dynamic embedding of Python. + Decrement the reference count for object *o*. A function version of :c:func:`Py_XDECREF`. + It can be used for runtime dynamic embedding of Python. The following functions or macros are only for use within the interpreter core: