Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve C API guidelines for return values #1129

Closed
Changes from 5 commits
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
8 changes: 5 additions & 3 deletions developer-workflow/c-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ Guidelines for expanding/changing the public API
fields, arguments and return values are well defined.

- Functions returning ``PyObject *`` must return a valid pointer on success,
and ``NULL`` with an exception raised on error.
Most other API must return ``-1`` with an exception raised on error,
and ``0`` on success.
and ``NULL`` if and only if an exception is raised.
Other API must return ``0`` on success,
erlend-aasland marked this conversation as resolved.
Show resolved Hide resolved
and a negative value if and only if an exception is raised.
``-1`` should be used as the error value;
the caller should use the C idiom ``if (func() < 0)`` to check for errors.

- APIs with lesser and greater results must return ``0`` for the lesser result,
and ``1`` for the greater result.
Expand Down
Loading