Skip to content

gh-67377: Document that PyErr_SetString, etc. chain exceptions #20329

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ Raising exceptions

These functions help you set the current thread's error indicator.
For convenience, some of these functions will always return a
``NULL`` pointer for use in a ``return`` statement.
``NULL`` pointer for use in a ``return`` statement. Also, for all of the
functions in this subsection, if an exception has already been caught,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serhiy-storchaka raised an issue with this terminology, I don't think the previous reviewers' comments have been addressed: #20329 (comment)

that exception will be implicitly chained (i.e. the last caught exception
will become the new exception's :attr:`~BaseException.__context__`).


.. c:function:: void PyErr_SetString(PyObject *type, const char *message)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Mention that :c:func:`PyErr_SetString`, :c:func:`PyErr_SetObject`, and
friends implicitly chain exceptions.
Loading