diff -r 0e438442fddf Doc/reference/simple_stmts.rst --- a/Doc/reference/simple_stmts.rst Fri Mar 14 21:39:18 2014 -0500 +++ b/Doc/reference/simple_stmts.rst Sat Mar 15 12:10:43 2014 +0100 @@ -555,6 +555,29 @@ + +Document 'from None' in raise statement doc +--------------------------------------------- The from clause is used for exception chaining: if given, the second expression +may be another exception class or instance or `None`, which will then be attached to the raised exception as the :attr:`__cause__` attribute (which is writable). + >>> try: + ... print(1 / 0) + ... except: + ... raise RuntimeError("Something bad happened") from None + ... + Traceback (most recent call last): + File "", line 4, in + RuntimeError: Something bad happened + + A similar mechanism works implicitly if an exception is raised inside an exception handler: the previous exception is then attached as the new exception's :attr:`__context__` attribute:: File "", line 4, in RuntimeError: Something bad happened + +.. versionchanged:: 3.3 + :const:`None` is now permitted as ``Y`` in ``raise X from Y`` + +.. versionadded:: 3.3 + The ``__supress_context__`` attribute to suppress automatic display of the + exception context + +The :const:`from None` clause can be used to suppress the old exception with +the new one for display purposes. This will set the +:attr:`__suppress_context__` attribute to :const:`True` while leaving the old +exception available in :attr:`__context__` for introspection when debugging::