implicitly set __suppress_context__ when __cause__ is set
This commit is contained in:
parent
80357b7f9a
commit
0ba175b321
15
pep-0415.txt
15
pep-0415.txt
|
@ -42,11 +42,12 @@ Proposal
|
|||
========
|
||||
|
||||
A new attribute on ``BaseException``, ``__suppress_context__``, will
|
||||
be introduced. The ``raise exc from cause`` syntax will set
|
||||
``exc.__suppress_context__`` to ``True``. Exception printing code will
|
||||
check for that attribute to determine whether context and cause will
|
||||
be printed. ``__cause__`` will return to its original purpose and
|
||||
values.
|
||||
be introduced. Whenever ``__cause__`` is set, ``__suppress_context__``
|
||||
will be set to ``True``. In particular, ``raise exc from cause``
|
||||
syntax will set ``exc.__suppress_context__`` to ``True``. Exception
|
||||
printing code will check for that attribute to determine whether
|
||||
context and cause will be printed. ``__cause__`` will return to its
|
||||
original purpose and values.
|
||||
|
||||
There is precedence for ``__suppress_context__`` with the
|
||||
``print_line_and_file`` exception attribute.
|
||||
|
@ -54,9 +55,11 @@ There is precedence for ``__suppress_context__`` with the
|
|||
To summarize, ``raise exc from cause`` will be equivalent to::
|
||||
|
||||
exc.__cause__ = cause
|
||||
exc.__suppress_context__ = True
|
||||
raise exc
|
||||
|
||||
where ``exc.__cause__ = cause`` implicitly sets
|
||||
``exc.__suppress_context__``.
|
||||
|
||||
Patches
|
||||
=======
|
||||
|
||||
|
|
Loading…
Reference in New Issue