mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.11] gh-101100: Improve docs on exception attributes (GH-113057) (#113062)
gh-101100: Improve docs on exception attributes (GH-113057)
(cherry picked from commit d05a180350
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
5fd915df6e
commit
9b3447ca3c
6 changed files with 110 additions and 62 deletions
|
@ -456,7 +456,8 @@ Querying the error indicator
|
|||
|
||||
.. note::
|
||||
|
||||
This function *does not* implicitly set the ``__traceback__``
|
||||
This function *does not* implicitly set the
|
||||
:attr:`~BaseException.__traceback__`
|
||||
attribute on the exception value. If setting the traceback
|
||||
appropriately is desired, the following additional snippet is needed::
|
||||
|
||||
|
@ -668,7 +669,8 @@ Exception Objects
|
|||
.. c:function:: PyObject* PyException_GetTraceback(PyObject *ex)
|
||||
|
||||
Return the traceback associated with the exception as a new reference, as
|
||||
accessible from Python through :attr:`__traceback__`. If there is no
|
||||
accessible from Python through the :attr:`~BaseException.__traceback__`
|
||||
attribute. If there is no
|
||||
traceback associated, this returns ``NULL``.
|
||||
|
||||
|
||||
|
@ -682,8 +684,8 @@ Exception Objects
|
|||
|
||||
Return the context (another exception instance during whose handling *ex* was
|
||||
raised) associated with the exception as a new reference, as accessible from
|
||||
Python through :attr:`__context__`. If there is no context associated, this
|
||||
returns ``NULL``.
|
||||
Python through the :attr:`~BaseException.__context__` attribute.
|
||||
If there is no context associated, this returns ``NULL``.
|
||||
|
||||
|
||||
.. c:function:: void PyException_SetContext(PyObject *ex, PyObject *ctx)
|
||||
|
@ -697,7 +699,8 @@ Exception Objects
|
|||
|
||||
Return the cause (either an exception instance, or ``None``,
|
||||
set by ``raise ... from ...``) associated with the exception as a new
|
||||
reference, as accessible from Python through :attr:`__cause__`.
|
||||
reference, as accessible from Python through the
|
||||
:attr:`~BaseException.__cause__` attribute.
|
||||
|
||||
|
||||
.. c:function:: void PyException_SetCause(PyObject *ex, PyObject *cause)
|
||||
|
@ -706,7 +709,8 @@ Exception Objects
|
|||
it. There is no type check to make sure that *cause* is either an exception
|
||||
instance or ``None``. This steals a reference to *cause*.
|
||||
|
||||
:attr:`__suppress_context__` is implicitly set to ``True`` by this function.
|
||||
The :attr:`~BaseException.__suppress_context__` attribute is implicitly set
|
||||
to ``True`` by this function.
|
||||
|
||||
|
||||
.. _unicodeexceptions:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue