Skip to content

Commit 40a23a1

Browse files
iritkatrielbentasker
authored andcommitted
pythongh-84436: update docs on Py_None/Py_True/Py_False/Py_Ellipsis becoming immortal (python#105195)
1 parent 62c676f commit 40a23a1

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

Doc/c-api/bool.rst

+14-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Boolean Objects
66
---------------
77

88
Booleans in Python are implemented as a subclass of integers. There are only
9-
two booleans, :const:`Py_False` and :const:`Py_True`. As such, the normal
9+
two booleans, :c:data:`Py_False` and :c:data:`Py_True`. As such, the normal
1010
creation and deletion functions don't apply to booleans. The following macros
1111
are available, however.
1212

@@ -19,29 +19,32 @@ are available, however.
1919
2020
.. c:var:: PyObject* Py_False
2121
22-
The Python ``False`` object. This object has no methods. It needs to be
23-
treated just like any other object with respect to reference counts.
22+
The Python ``False`` object. This object has no methods and is
23+
`immortal <https://peps.python.org/pep-0683/>`_.
24+
25+
.. versionchanged:: 3.12
26+
:c:data:`Py_False` is immortal.
2427
2528
2629
.. c:var:: PyObject* Py_True
2730
28-
The Python ``True`` object. This object has no methods. It needs to be treated
29-
just like any other object with respect to reference counts.
31+
The Python ``True`` object. This object has no methods and is
32+
`immortal <https://peps.python.org/pep-0683/>`_.
33+
34+
.. versionchanged:: 3.12
35+
:c:data:`Py_True` is immortal.
3036
3137
3238
.. c:macro:: Py_RETURN_FALSE
3339
34-
Return :const:`Py_False` from a function, properly incrementing its reference
35-
count.
40+
Return :c:data:`Py_False` from a function.
3641
3742
3843
.. c:macro:: Py_RETURN_TRUE
3944
40-
Return :const:`Py_True` from a function, properly incrementing its reference
41-
count.
45+
Return :c:data:`Py_True` from a function.
4246
4347
4448
.. c:function:: PyObject* PyBool_FromLong(long v)
4549
46-
Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
47-
truth value of *v*.
50+
Return :c:data:`Py_True` or :c:data:`Py_False`, depending on the truth value of *v*.

Doc/c-api/none.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ same reason.
1515

1616
.. c:var:: PyObject* Py_None
1717
18-
The Python ``None`` object, denoting lack of value. This object has no methods.
19-
It needs to be treated just like any other object with respect to reference
20-
counts.
18+
The Python ``None`` object, denoting lack of value. This object has no methods
19+
and is `immortal <https://peps.python.org/pep-0683/>`_.
2120

21+
.. versionchanged:: 3.12
22+
:c:data:`Py_None` is immortal.
2223

2324
.. c:macro:: Py_RETURN_NONE
2425
25-
Properly handle returning :c:data:`Py_None` from within a C function (that is,
26-
increment the reference count of ``None`` and return it.)
26+
Return :c:data:`Py_None` from a function.

Doc/c-api/slice.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ Ellipsis Object
118118
119119
.. c:var:: PyObject *Py_Ellipsis
120120
121-
The Python ``Ellipsis`` object. This object has no methods. It needs to be
122-
treated just like any other object with respect to reference counts. Like
123-
:c:data:`Py_None` it is a singleton object.
121+
The Python ``Ellipsis`` object. This object has no methods. Like
122+
:c:data:`Py_None`, it is an `immortal <https://peps.python.org/pep-0683/>`_.
123+
singleton object.
124+
125+
.. versionchanged:: 3.12
126+
:c:data:`Py_Ellipsis` is immortal.

0 commit comments

Comments
 (0)