Skip to content

gh-150663: Document that PyErr_SetRaisedException() accepts NULL#150705

Closed
philthompson10 wants to merge 187 commits into
python:mainfrom
philthompson10:issue/150663
Closed

gh-150663: Document that PyErr_SetRaisedException() accepts NULL#150705
philthompson10 wants to merge 187 commits into
python:mainfrom
philthompson10:issue/150663

Conversation

@philthompson10

@philthompson10 philthompson10 commented Jun 1, 2026

Copy link
Copy Markdown

Documented that PyErr_SetRaisedException() accepts NULL as the value of the exception being set.

Documented that `PyErr_SetRaisedException()` accepts `NULL` as the value of
the exception being set.
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Jun 1, 2026
@python-cla-bot

python-cla-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@read-the-docs-community

read-the-docs-community Bot commented Jun 1, 2026

Copy link
Copy Markdown

Comment thread Doc/c-api/exceptions.rst Outdated
.. warning::

This call steals a reference to *exc*, which must be a valid exception.
*exc* must be a valid exception (in which case a reference is stolen) or

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.

The fact that it can be NULL should not be in a warning.

Comment thread Doc/c-api/exceptions.rst Outdated
Comment on lines +501 to +502
A stolen reference to *exc* is set as the exception currently being raised,
clearing the existing exception if one is set. *exc* may be ``NULL`` in

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.

Keep the warning, but only use it for the note about reference stealing. The sentence about exc being NULL should go in the body.

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 that it is better to use note instead of warning, like in PyList_SetItem and many other functions that steal references.

I suggest to add "If exc is NULL, just clear the existing exception." to the body and replace warning with note.

@philthompson10

philthompson10 commented Jun 3, 2026 via email

Copy link
Copy Markdown
Author

@ZeroIntensity

Copy link
Copy Markdown
Member
  1. It was there before and not causing any problems, so I don't see why we need to change it here. Doing so just makes merging this more prone to friction.
  2. More generally, I don't think it's a good idea to base documentation decisions about PyErr_SetRaisedException on PyErr_Restore. By design, PyErr_SetRaisedException is much easier to use without a call to PyErr_GetRaisedException; in contrast, PyErr_Restore is almost exclusively called with a pair to PyErr_Fetch (because it's hard to get the exception triple from an arbitrary exception object), which makes it clearer that stealing is the intended choice.

LindaSummer and others added 13 commits June 17, 2026 18:22
…GH-150580)

Co-authored-by: Charlie Lin <tuug@gmx.us>
Co-authored-by: da-woods <dw-git@d-woods.co.uk>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* Correct Stable ABI documentation for METH_FASTCALL

The current documentation says:

> 
> METH_FASTCALL
>    Part of the Stable ABI since version 3.7.
>
> [...]
>
>   Added in version 3.7.
>
>    Changed in version 3.10: METH_FASTCALL is now part of the stable ABI.

so is contradictory about when it was added to the Stable ABI.  Looking at the header it seems like 3.10 is right.
…es (python#133504)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Brett Cannon <brett@python.org>
Removes some stray commas in help text.
Following on from pythonGH-132291 this is the second part of the patch from https://bugs.debian.org/1101406

This tweaks the formatting of a few bits of the manpage.
…ython#148846)

There are propositions to add a single-quote-double-quote switch
(pythongh-90630), so to avoid hiccups of people passing `force` as a
positional and it being used for the single-double switch, we make
kwargs kwargs-only.

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
@hugovk

hugovk commented Jun 17, 2026

Copy link
Copy Markdown
Member

@philthompson10 For next time: please don't rebase or force push PRs. We squash merge at the end, and it's easier to review without force pushes. Also force pushes can end up spamming all the CODEOWNERS.

If the branch is out of date with main, merge it into the feature branch. But often that's not needed unless there's something you specifically need from main or if it's been a long time.

https://devguide.python.org/getting-started/pull-request-lifecycle/#don-t-force-push

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.