Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a note about integer return values.
  • Loading branch information
ZeroIntensity committed May 18, 2026
commit 182d190d581ec24e608d93a242cf54c0bafda948
10 changes: 9 additions & 1 deletion Doc/extending/error-handling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ we can see this in action:


``spam_system`` returns a ``PyObject *``, so we indicate failure by returning
``NULL``. To expand on this, let's try to modify ``spam_system`` to raise an
``NULL``.

.. note::

Some functions in the C API return an ``int`` instead of a reference, so they
cannot use ``NULL`` for failure. These functions will usually return ``-1``
for failure, and ``0`` otherwise.

To expand on this, let's try to modify ``spam_system`` to raise an
exception if the result is non-zero:

.. code-block:: c
Expand Down
Loading