From 4346e2541e7290a773e1ffe70eebe7d5638fccd8 Mon Sep 17 00:00:00 2001 From: hrimov Date: Sat, 4 Jul 2026 20:59:34 +0200 Subject: [PATCH 1/2] Document that PyErr_SetRaisedException accepts null --- Doc/c-api/exceptions.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 78c95791ab3104..a7e66f8fc074da 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -499,12 +499,12 @@ Querying the error indicator .. c:function:: void PyErr_SetRaisedException(PyObject *exc) Set *exc* as the exception currently being raised, - clearing the existing exception if one is set. + clearing the existing exception if one is set. *exc* may be ``NULL``, + in which case the current exception is cleared without setting a new one. .. warning:: - This call ":term:`steals `" a reference to *exc*, - which must be a valid exception. + This call ":term:`steals `" a reference to *exc*. .. versionadded:: 3.12 From ba554115505a653f871e5849ad1b19c7c795a96e Mon Sep 17 00:00:00 2001 From: hrimov Date: Sat, 4 Jul 2026 22:35:57 +0200 Subject: [PATCH 2/2] Use note instead of warning and tweak null wording --- Doc/c-api/exceptions.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index a7e66f8fc074da..c2ded0b36a3613 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -499,10 +499,10 @@ Querying the error indicator .. c:function:: void PyErr_SetRaisedException(PyObject *exc) Set *exc* as the exception currently being raised, - clearing the existing exception if one is set. *exc* may be ``NULL``, - in which case the current exception is cleared without setting a new one. + clearing the existing exception if one is set. If *exc* is ``NULL``, + just clear the existing exception. - .. warning:: + .. note:: This call ":term:`steals `" a reference to *exc*.