Add better error reporting for MemoryErrors caused by str->float conversions.
[python.git] / Doc / c-api / bool.rst
blob2bf6e7e511137883fa3d1a08fd53132f297c159e
1 .. highlightlang:: c
3 .. _boolobjects:
5 Boolean Objects
6 ---------------
8 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
10 creation and deletion functions don't apply to booleans.  The following macros
11 are available, however.
14 .. cfunction:: int PyBool_Check(PyObject *o)
16    Return true if *o* is of type :cdata:`PyBool_Type`.
18    .. versionadded:: 2.3
21 .. cvar:: PyObject* Py_False
23    The Python ``False`` object.  This object has no methods.  It needs to be
24    treated just like any other object with respect to reference counts.
27 .. cvar:: PyObject* Py_True
29    The Python ``True`` object.  This object has no methods.  It needs to be treated
30    just like any other object with respect to reference counts.
33 .. cmacro:: Py_RETURN_FALSE
35    Return :const:`Py_False` from a function, properly incrementing its reference
36    count.
38    .. versionadded:: 2.4
41 .. cmacro:: Py_RETURN_TRUE
43    Return :const:`Py_True` from a function, properly incrementing its reference
44    count.
46    .. versionadded:: 2.4
49 .. cfunction:: PyObject* PyBool_FromLong(long v)
51    Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
52    truth value of *v*.
54    .. versionadded:: 2.3