[Python-checkins] peps: implicitly set __suppress_context__ when __cause__ is set

benjamin.peterson python-checkins at python.org
Mon Mar 5 22:43:45 CET 2012


http://hg.python.org/peps/rev/0a7019500350
changeset:   4118:0a7019500350
user:        Benjamin Peterson <benjamin at python.org>
date:        Mon Mar 05 15:43:34 2012 -0600
summary:
  implicitly set __suppress_context__ when __cause__ is set

files:
  pep-0415.txt |  15 +++++++++------
  1 files changed, 9 insertions(+), 6 deletions(-)


diff --git a/pep-0415.txt b/pep-0415.txt
--- a/pep-0415.txt
+++ b/pep-0415.txt
@@ -42,11 +42,12 @@
 ========
 
 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 @@
 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
 =======
 

-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list