Skip to content

Commit 182d190

Browse files
committed
Add a note about integer return values.
1 parent 5f40e3e commit 182d190

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Doc/extending/error-handling.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ we can see this in action:
5353
5454
5555
``spam_system`` returns a ``PyObject *``, so we indicate failure by returning
56-
``NULL``. To expand on this, let's try to modify ``spam_system`` to raise an
56+
``NULL``.
57+
58+
.. note::
59+
60+
Some functions in the C API return an ``int`` instead of a reference, so they
61+
cannot use ``NULL`` for failure. These functions will usually return ``-1``
62+
for failure, and ``0`` otherwise.
63+
64+
To expand on this, let's try to modify ``spam_system`` to raise an
5765
exception if the result is non-zero:
5866

5967
.. code-block:: c

0 commit comments

Comments
 (0)