Skip to content

gh-150663: Document that PyErr_SetRaisedException accepts null#153046

Open
hrimov wants to merge 2 commits into
python:mainfrom
hrimov:doc-pyerr-set-raised-exc-null
Open

gh-150663: Document that PyErr_SetRaisedException accepts null#153046
hrimov wants to merge 2 commits into
python:mainfrom
hrimov:doc-pyerr-set-raised-exc-null

Conversation

@hrimov

@hrimov hrimov commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

@read-the-docs-community

read-the-docs-community Bot commented Jul 4, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33441999 | 📁 Comparing ba55411 against main (bcf98dd)

  🔍 Preview build  

2 files changed
± c-api/exceptions.html
± whatsnew/changelog.html

Comment thread Doc/c-api/exceptions.rst
.. note::

This call ":term:`steals <steal>`" a reference to *exc*,
which must be a valid exception.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this line is helpful. We should just say "must be a valid exception or NULL".

Comment thread Doc/c-api/exceptions.rst
Set *exc* as the exception currently being raised,
clearing the existing exception if one is set.
clearing the existing exception if one is set. If *exc* is ``NULL``,
just clear the existing exception.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest adding a new paragraph:

*exc must be a valid exception or ``NULL``.

Comment thread Doc/c-api/exceptions.rst
just clear the existing exception.

.. warning::
.. note::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think that it deserves to be documented as a note. Other PyErr functions also steal a reference, and they don't use a note or warning, but just write it in the documentation body.

Comment thread Doc/c-api/exceptions.rst
Set *exc* as the exception currently being raised,
clearing the existing exception if one is set.
clearing the existing exception if one is set. If *exc* is ``NULL``,
just clear the existing exception.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
just clear the existing exception.
just clear the existing exception.
This call ":term:`steals <steal>`" a reference to *exc*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants