summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-24 21:17:33 (GMT)
committerGitHub <noreply@github.com>2022-11-24 21:17:33 (GMT)
commit3a803bcaacece466e9c137fb4a3c6389780377d6 (patch)
tree5fdf966acc242cd18f693468b0102d7299d9d2ec /Doc/c-api
parent0da728387c99fe6c127b070f2d250dc5bdd62ee5 (diff)
downloadcpython-3a803bcaacece466e9c137fb4a3c6389780377d6.zip
cpython-3a803bcaacece466e9c137fb4a3c6389780377d6.tar.gz
cpython-3a803bcaacece466e9c137fb4a3c6389780377d6.tar.bz2
Revert "gh-98724: Fix Py_CLEAR() macro side effects" (#99737)
Revert "gh-98724: Fix Py_CLEAR() macro side effects (#99100)" This reverts commit c03e05c2e72f3ea5e797389e7d1042eef85ad37a.
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/refcounting.rst46
1 files changed, 2 insertions, 44 deletions
diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst
index d8e9c2d..cd1f2ef 100644
--- a/Doc/c-api/refcounting.rst
+++ b/Doc/c-api/refcounting.rst
@@ -7,8 +7,8 @@
Reference Counting
******************
-The functions and macros in this section are used for managing reference counts
-of Python objects.
+The macros in this section are used for managing reference counts of Python
+objects.
.. c:function:: Py_ssize_t Py_REFCNT(PyObject *o)
@@ -129,11 +129,6 @@ of Python 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.
- .. versionchanged:: 3.12
- The macro argument is now only evaluated once. If the argument has side
- effects, these are no longer duplicated.
-
-
.. c:function:: void Py_IncRef(PyObject *o)
Increment the reference count for object *o*. A function version of :c:func:`Py_XINCREF`.
@@ -144,40 +139,3 @@ of Python objects.
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.
-
-
-.. c:macro:: Py_SETREF(dst, src)
-
- Macro safely decrementing the `dst` reference count and setting `dst` to
- `src`.
-
- As in case of :c:func:`Py_CLEAR`, "the obvious" code can be deadly::
-
- Py_DECREF(dst);
- dst = src;
-
- The safe way is::
-
- Py_SETREF(dst, src);
-
- That arranges to set `dst` to `src` _before_ decrementing reference count of
- *dst* old value, so that any code triggered as a side-effect of `dst`
- getting torn down no longer believes `dst` points to a valid object.
-
- .. versionadded:: 3.6
-
- .. versionchanged:: 3.12
- The macro arguments are now only evaluated once. If an argument has side
- effects, these are no longer duplicated.
-
-
-.. c:macro:: Py_XSETREF(dst, src)
-
- Variant of :c:macro:`Py_SETREF` macro that uses :c:func:`Py_XDECREF` instead
- of :c:func:`Py_DECREF`.
-
- .. versionadded:: 3.6
-
- .. versionchanged:: 3.12
- The macro arguments are now only evaluated once. If an argument has side
- effects, these are no longer duplicated.