Skip to content

Commit 02d9f15

Browse files
pythongh-101578: Amend exception docs (python#102057)
Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent 6f25657 commit 02d9f15

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

Doc/c-api/exceptions.rst

+23-22
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,9 @@ Querying the error indicator
438438
439439
.. c:function:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
440440
441-
As of 3.12, this function is deprecated. Use :c:func:`PyErr_GetRaisedException` instead.
441+
.. deprecated:: 3.12
442+
443+
Use :c:func:`PyErr_GetRaisedException` instead.
442444
443445
Retrieve the error indicator into three variables whose addresses are passed.
444446
If the error indicator is not set, set all three variables to ``NULL``. If it is
@@ -447,8 +449,10 @@ Querying the error indicator
447449
448450
.. note::
449451
450-
This function is normally only used by code that needs to catch exceptions or
451-
by code that needs to save and restore the error indicator temporarily, e.g.::
452+
This function is normally only used by legacy code that needs to catch
453+
exceptions or save and restore the error indicator temporarily.
454+
455+
For example::
452456
453457
{
454458
PyObject *type, *value, *traceback;
@@ -459,15 +463,17 @@ Querying the error indicator
459463
PyErr_Restore(type, value, traceback);
460464
}
461465
462-
.. deprecated:: 3.12
463-
464466
465467
.. c:function:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
466468
467-
As of 3.12, this function is deprecated. Use :c:func:`PyErr_SetRaisedException` instead.
469+
.. deprecated:: 3.12
470+
471+
Use :c:func:`PyErr_SetRaisedException` instead.
468472
469-
Set the error indicator from the three objects. If the error indicator is
470-
already set, it is cleared first. If the objects are ``NULL``, the error
473+
Set the error indicator from the three objects,
474+
*type*, *value*, and *traceback*,
475+
clearing the existing exception if one is set.
476+
If the objects are ``NULL``, the error
471477
indicator is cleared. Do not pass a ``NULL`` type and non-``NULL`` value or
472478
traceback. The exception type should be a class. Do not pass an invalid
473479
exception type or value. (Violating these rules will cause subtle problems
@@ -478,18 +484,17 @@ Querying the error indicator
478484
479485
.. note::
480486
481-
This function is normally only used by code that needs to save and restore the
482-
error indicator temporarily. Use :c:func:`PyErr_Fetch` to save the current
483-
error indicator.
484-
485-
.. deprecated:: 3.12
487+
This function is normally only used by legacy code that needs to
488+
save and restore the error indicator temporarily.
489+
Use :c:func:`PyErr_Fetch` to save the current error indicator.
486490
487491
488492
.. c:function:: void PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
489493
490-
As of 3.12, this function is deprecated.
491-
Use :c:func:`PyErr_GetRaisedException` instead of :c:func:`PyErr_Fetch` to avoid
492-
any possible de-normalization.
494+
.. deprecated:: 3.12
495+
496+
Use :c:func:`PyErr_GetRaisedException` instead,
497+
to avoid any possible de-normalization.
493498
494499
Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` below
495500
can be "unnormalized", meaning that ``*exc`` is a class object but ``*val`` is
@@ -507,8 +512,6 @@ Querying the error indicator
507512
PyException_SetTraceback(val, tb);
508513
}
509514
510-
.. deprecated:: 3.12
511-
512515
513516
.. c:function:: PyObject* PyErr_GetHandledException(void)
514517
@@ -756,14 +759,12 @@ Exception Objects
756759
757760
.. c:function:: PyObject* PyException_GetArgs(PyObject *ex)
758761
759-
Return args of the given exception as a new reference,
760-
as accessible from Python through :attr:`args`.
762+
Return :attr:`~BaseException.args` of exception *ex*.
761763
762764
763765
.. c:function:: void PyException_SetArgs(PyObject *ex, PyObject *args)
764766
765-
Set the args of the given exception,
766-
as accessible from Python through :attr:`args`.
767+
Set :attr:`~BaseException.args` of exception *ex* to *args*.
767768
768769
769770
.. _unicodeexceptions:

Doc/data/refcounts.dat

+2
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ PyEval_EvalFrameEx:int:throwflag::
839839
PyEval_MergeCompilerFlags:int:::
840840
PyEval_MergeCompilerFlags:PyCompilerFlags*:cf::
841841

842+
PyException_GetArgs:PyObject*::+1:
843+
842844
PyException_GetCause:PyObject*::+1:
843845
PyException_GetCause:PyObject*:ex:0:
844846

0 commit comments

Comments
 (0)