blob: b9ac26921d5947bb19cdd0e4f4fe662c1f277f1a [file] [log] [blame]
Georg Brandl54a3faa2008-01-20 09:30:57 +00001.. highlightlang:: c
2
3.. _noneobject:
4
5The None Object
6---------------
7
8.. index:: object: None
9
Georg Brandl60203b42010-10-06 10:11:56 +000010Note that the :c:type:`PyTypeObject` for ``None`` is not directly exposed in the
Georg Brandl54a3faa2008-01-20 09:30:57 +000011Python/C API. Since ``None`` is a singleton, testing for object identity (using
Georg Brandl60203b42010-10-06 10:11:56 +000012``==`` in C) is sufficient. There is no :c:func:`PyNone_Check` function for the
Georg Brandl54a3faa2008-01-20 09:30:57 +000013same reason.
14
15
Georg Brandl60203b42010-10-06 10:11:56 +000016.. c:var:: PyObject* Py_None
Georg Brandl54a3faa2008-01-20 09:30:57 +000017
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.
21
22
Georg Brandl60203b42010-10-06 10:11:56 +000023.. c:macro:: Py_RETURN_NONE
Georg Brandl54a3faa2008-01-20 09:30:57 +000024
Georg Brandl60203b42010-10-06 10:11:56 +000025 Properly handle returning :c:data:`Py_None` from within a C function (that is,
Georg Brandl54a3faa2008-01-20 09:30:57 +000026 increment the reference count of None and return it.)