Skip to content

Commit

Permalink
pythongh-101578: Amend exception docs
Browse files Browse the repository at this point in the history
Follow-up to pythongh-101962
  • Loading branch information
erlend-aasland committed Feb 19, 2023
1 parent 60bbed7 commit 3a4a570
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -438,17 +438,18 @@ Querying the error indicator
.. c:function:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
As of 3.12, this function is deprecated. Use :c:func:`PyErr_GetRaisedException` instead.
Retrieve the error indicator into three variables whose addresses are passed.
If the error indicator is not set, set all three variables to ``NULL``. If it is
set, it will be cleared and you own a reference to each object retrieved. The
value and traceback object may be ``NULL`` even when the type object is not.
.. note::
This function is normally only used by code that needs to catch exceptions or
by code that needs to save and restore the error indicator temporarily, e.g.::
This function is normally only used by legacy code that needs to catch
exceptions or by code that needs to save and restore the error indicator
temporarily.
For example::
{
PyObject *type, *value, *traceback;
Expand All @@ -461,10 +462,10 @@ Querying the error indicator
.. deprecated:: 3.12
Use :c:func:`PyErr_GetRaisedException` instead.
.. c:function:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
As of 3.12, this function is deprecated. Use :c:func:`PyErr_SetRaisedException` instead.
.. c:function:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
Set the error indicator from the three objects. If the error indicator is
already set, it is cleared first. If the objects are ``NULL``, the error
Expand All @@ -478,18 +479,16 @@ Querying the error indicator
.. note::
This function is normally only used by code that needs to save and restore the
error indicator temporarily. Use :c:func:`PyErr_Fetch` to save the current
error indicator.
This function is normally only used by legacy code that needs to
save and restore the error indicator temporarily.
Use :c:func:`PyErr_Fetch` to save the current error indicator.
.. deprecated:: 3.12
Use :c:func:`PyErr_SetRaisedException` instead.
.. c:function:: void PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
As of 3.12, this function is deprecated.
Use :c:func:`PyErr_GetRaisedException` instead of :c:func:`PyErr_Fetch` to avoid
any possible de-normalization.
.. c:function:: void PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` below
can be "unnormalized", meaning that ``*exc`` is a class object but ``*val`` is
Expand All @@ -509,6 +508,9 @@ Querying the error indicator
.. deprecated:: 3.12
Use :c:func:`PyErr_GetRaisedException` instead,
to avoid any possible de-normalization.
.. c:function:: PyObject* PyErr_GetHandledException(void)
Expand Down Expand Up @@ -756,14 +758,12 @@ Exception Objects
.. c:function:: PyObject* PyException_GetArgs(PyObject *ex)
Return args of the given exception as a new reference,
as accessible from Python through :attr:`args`.
Return :attr:`~BaseException.args` of exception *ex*.
.. c:function:: void PyException_SetArgs(PyObject *ex, PyObject *args)
Set the args of the given exception,
as accessible from Python through :attr:`args`.
Set :attr:`~BaseException.args` of exception *ex* to *args*:
.. _unicodeexceptions:
Expand Down
2 changes: 2 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,8 @@ PyEval_EvalFrameEx:int:throwflag::
PyEval_MergeCompilerFlags:int:::
PyEval_MergeCompilerFlags:PyCompilerFlags*:cf::

PyException_GetArgs:PyObject*::+1:

PyException_GetCause:PyObject*::+1:
PyException_GetCause:PyObject*:ex:0:

Expand Down

0 comments on commit 3a4a570

Please sign in to comment.