implicitly set __suppress_context__ when __cause__ is set

This commit is contained in:
Benjamin Peterson 2012-03-05 15:43:34 -06:00
parent 80357b7f9a
commit 0ba175b321
1 changed files with 9 additions and 6 deletions

View File

@ -42,11 +42,12 @@ Proposal
======== ========
A new attribute on ``BaseException``, ``__suppress_context__``, will A new attribute on ``BaseException``, ``__suppress_context__``, will
be introduced. The ``raise exc from cause`` syntax will set be introduced. Whenever ``__cause__`` is set, ``__suppress_context__``
``exc.__suppress_context__`` to ``True``. Exception printing code will will be set to ``True``. In particular, ``raise exc from cause``
check for that attribute to determine whether context and cause will syntax will set ``exc.__suppress_context__`` to ``True``. Exception
be printed. ``__cause__`` will return to its original purpose and printing code will check for that attribute to determine whether
values. context and cause will be printed. ``__cause__`` will return to its
original purpose and values.
There is precedence for ``__suppress_context__`` with the There is precedence for ``__suppress_context__`` with the
``print_line_and_file`` exception attribute. ``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:: To summarize, ``raise exc from cause`` will be equivalent to::
exc.__cause__ = cause exc.__cause__ = cause
exc.__suppress_context__ = True
raise exc raise exc
where ``exc.__cause__ = cause`` implicitly sets
``exc.__suppress_context__``.
Patches Patches
======= =======