mirror of
https://github.com/python/cpython.git
synced 2025-08-09 03:19:15 +00:00
[3.12] gh-84436: update docs on Py_None/Py_True/Py_False/Py_Ellipsis becoming immortal (GH-105195) (#105977)
gh-84436: update docs on Py_None/Py_True/Py_False/Py_Ellipsis becoming immortal (GH-105195)
(cherry picked from commit a2392720d6
)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
parent
b786fe8a09
commit
592d1eadc6
3 changed files with 25 additions and 19 deletions
|
@ -6,7 +6,7 @@ Boolean Objects
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Booleans in Python are implemented as a subclass of integers. There are only
|
Booleans in Python are implemented as a subclass of integers. There are only
|
||||||
two booleans, :const:`Py_False` and :const:`Py_True`. As such, the normal
|
two booleans, :c:data:`Py_False` and :c:data:`Py_True`. As such, the normal
|
||||||
creation and deletion functions don't apply to booleans. The following macros
|
creation and deletion functions don't apply to booleans. The following macros
|
||||||
are available, however.
|
are available, however.
|
||||||
|
|
||||||
|
@ -19,29 +19,32 @@ are available, however.
|
||||||
|
|
||||||
.. c:var:: PyObject* Py_False
|
.. c:var:: PyObject* Py_False
|
||||||
|
|
||||||
The Python ``False`` object. This object has no methods. It needs to be
|
The Python ``False`` object. This object has no methods and is
|
||||||
treated just like any other object with respect to reference counts.
|
`immortal <https://peps.python.org/pep-0683/>`_.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.12
|
||||||
|
:c:data:`Py_False` is immortal.
|
||||||
|
|
||||||
|
|
||||||
.. c:var:: PyObject* Py_True
|
.. c:var:: PyObject* Py_True
|
||||||
|
|
||||||
The Python ``True`` object. This object has no methods. It needs to be treated
|
The Python ``True`` object. This object has no methods and is
|
||||||
just like any other object with respect to reference counts.
|
`immortal <https://peps.python.org/pep-0683/>`_.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.12
|
||||||
|
:c:data:`Py_True` is immortal.
|
||||||
|
|
||||||
|
|
||||||
.. c:macro:: Py_RETURN_FALSE
|
.. c:macro:: Py_RETURN_FALSE
|
||||||
|
|
||||||
Return :const:`Py_False` from a function, properly incrementing its reference
|
Return :c:data:`Py_False` from a function.
|
||||||
count.
|
|
||||||
|
|
||||||
|
|
||||||
.. c:macro:: Py_RETURN_TRUE
|
.. c:macro:: Py_RETURN_TRUE
|
||||||
|
|
||||||
Return :const:`Py_True` from a function, properly incrementing its reference
|
Return :c:data:`Py_True` from a function.
|
||||||
count.
|
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: PyObject* PyBool_FromLong(long v)
|
.. c:function:: PyObject* PyBool_FromLong(long v)
|
||||||
|
|
||||||
Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
|
Return :c:data:`Py_True` or :c:data:`Py_False`, depending on the truth value of *v*.
|
||||||
truth value of *v*.
|
|
||||||
|
|
|
@ -15,12 +15,12 @@ same reason.
|
||||||
|
|
||||||
.. c:var:: PyObject* Py_None
|
.. c:var:: PyObject* Py_None
|
||||||
|
|
||||||
The Python ``None`` object, denoting lack of value. This object has no methods.
|
The Python ``None`` object, denoting lack of value. This object has no methods
|
||||||
It needs to be treated just like any other object with respect to reference
|
and is `immortal <https://peps.python.org/pep-0683/>`_.
|
||||||
counts.
|
|
||||||
|
|
||||||
|
.. versionchanged:: 3.12
|
||||||
|
:c:data:`Py_None` is immortal.
|
||||||
|
|
||||||
.. c:macro:: Py_RETURN_NONE
|
.. c:macro:: Py_RETURN_NONE
|
||||||
|
|
||||||
Properly handle returning :c:data:`Py_None` from within a C function (that is,
|
Return :c:data:`Py_None` from a function.
|
||||||
increment the reference count of ``None`` and return it.)
|
|
||||||
|
|
|
@ -118,6 +118,9 @@ Ellipsis Object
|
||||||
|
|
||||||
.. c:var:: PyObject *Py_Ellipsis
|
.. c:var:: PyObject *Py_Ellipsis
|
||||||
|
|
||||||
The Python ``Ellipsis`` object. This object has no methods. It needs to be
|
The Python ``Ellipsis`` object. This object has no methods. Like
|
||||||
treated just like any other object with respect to reference counts. Like
|
:c:data:`Py_None`, it is an `immortal <https://peps.python.org/pep-0683/>`_.
|
||||||
:c:data:`Py_None` it is a singleton object.
|
singleton object.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.12
|
||||||
|
:c:data:`Py_Ellipsis` is immortal.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue