@@ -402,51 +402,36 @@ Querying the error indicator
402402
403403.. c:function:: PyObject *PyErr_GetRaisedException(void)
404404
405- Returns the exception currently being raised, clearing the exception at
406- the same time. Do not confuse this with the exception currently being
407- handled which can be accessed with :c:func:`PyErr_GetHandledException`.
405+ Return the exception currently being raised, clearing the error indicator at
406+ the same time.
408407
409- .. note::
408+ This function is used by code that needs to catch exceptions,
409+ or code that needs to save and restore the error indicator temporarily.
410410
411- This function is normally only used by code that needs to catch exceptions or
412- by code that needs to save and restore the error indicator temporarily, e.g.::
411+ For example::
413412
414- {
415- PyObject *exc = PyErr_GetRaisedException();
413+ {
414+ PyObject *exc = PyErr_GetRaisedException();
416415
417- /* ... code that might produce other errors ... */
416+ /* ... code that might produce other errors ... */
418417
419- PyErr_SetRaisedException (exc);
420- }
418+ PyErr_SetRaisedException (exc);
419+ }
420+
421+ .. seealso :: :c:func:`PyErr_GetHandledException`,
422+ to save the exception currently being handled.
421423
422424 .. versionadded :: 3.12
423425
424426
425427.. c :function :: void PyErr_SetRaisedException (PyObject *exc)
426428
427- Sets the exception currently being raised ``exc ``.
428- If the exception is already set, it is cleared first.
429-
430- ``exc `` must be a valid exception.
431- (Violating this rules will cause subtle problems later.)
432- This call consumes a reference to the ``exc`` object: you must own a
433- reference to that object before the call and after the call you no longer own
434- that reference.
435- (If you don't understand this, don't use this function. I warned you.)
429+ Set *exc * as the exception currently being raised,
430+ clearing the existing exception if one is set.
436431
437- .. note::
438-
439- This function is normally only used by code that needs to save and restore the
440- error indicator temporarily. Use :c:func:`PyErr_GetRaisedException` to save
441- the current exception, e.g.::
442-
443- {
444- PyObject *exc = PyErr_GetRaisedException();
445-
446- /* ... code that might produce other errors ... */
432+ .. warning ::
447433
448- PyErr_SetRaisedException (exc);
449- }
434+ This call steals a reference to *exc *, which must be a valid exception.
450435
451436 .. versionadded :: 3.12
452437
0 commit comments