diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-05-15 05:09:31 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-05-15 05:09:31 (GMT) |
commit | d5a1c44455d969968f453f029727bfc45e4ce0a9 (patch) | |
tree | 98e91aa8130d600df0b1fdf329bbdc9d60d4b14c /Doc/library/exceptions.rst | |
parent | d91dc623791fd9973b914a57540d89cb986da7c9 (diff) | |
download | cpython-d5a1c44455d969968f453f029727bfc45e4ce0a9.zip cpython-d5a1c44455d969968f453f029727bfc45e4ce0a9.tar.gz cpython-d5a1c44455d969968f453f029727bfc45e4ce0a9.tar.bz2 |
PEP 415: Implement suppression of __context__ display with an exception attribute
This replaces the original PEP 409 implementation. See #14133.
Diffstat (limited to 'Doc/library/exceptions.rst')
-rw-r--r-- | Doc/library/exceptions.rst | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 33bc3b0..faf6732 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -39,18 +39,17 @@ When raising (or re-raising) an exception in an :keyword:`except` clause new exception is not handled the traceback that is eventually displayed will include the originating exception(s) and the final exception. -This implicit exception chain can be made explicit by using :keyword:`from` -with :keyword:`raise`. The single argument to :keyword:`from` must be an -exception or :const:`None`, and it will be set as :attr:`__cause__` on the -raised exception. If :attr:`__cause__` is an exception it will be displayed -instead of :attr:`__context__`; if :attr:`__cause__` is None, -:attr:`__context__` will not be displayed by the default exception handling -code. (Note: the default value for :attr:`__context__` is :const:`None`, -while the default value for :attr:`__cause__` is :const:`Ellipsis`.) - -In either case, the default exception handling code will not display -any of the remaining links in the :attr:`__context__` chain if -:attr:`__cause__` has been set. +This implicit exception chain can be made explicit by using :keyword:`from` with +:keyword:`raise`. The single argument to :keyword:`from` must be an exception +or ``None``. It will be set as :attr:`__cause__` on the raised exception. +Setting :attr:`__cause__` implicitly sets the :attr:`__suppress_context__` to +``True``. If :attr:`__cause__` is an exception, it will be displayed. If +:attr:`__cause__` is present or :attr:`__suppress_context__` has a true value, +:attr:`__context__` will not be displayed. + +In either case, the default exception handling code will not display any of the +remaining links in the :attr:`__context__` chain if :attr:`__cause__` has been +set. Base classes |