diff options
author | csabella <chekat2@gmail.com> | 2017-05-30 20:27:39 (GMT) |
---|---|---|
committer | Mariatta <Mariatta@users.noreply.github.com> | 2017-05-30 20:27:39 (GMT) |
commit | 00b381b9a7b6b15350d1dcf7c688bf808cbf0ebb (patch) | |
tree | 1e55ae6ceffea9348e825e374d0a1c6971bc7af5 | |
parent | 03c7600982027f4fbe5770c3caea59e08716374f (diff) | |
download | cpython-00b381b9a7b6b15350d1dcf7c688bf808cbf0ebb.zip cpython-00b381b9a7b6b15350d1dcf7c688bf808cbf0ebb.tar.gz cpython-00b381b9a7b6b15350d1dcf7c688bf808cbf0ebb.tar.bz2 |
bpo-17188: DOC: Document 'from None' in raise statement (GH-1671) (GH-1867)
Original patch by Dennis Mårtensson.
(cherry picked from commit 763557eac06ba60d7c5133e4f80df8870d8f917e)
-rw-r--r-- | Doc/reference/simple_stmts.rst | 22 | ||||
-rw-r--r-- | Misc/ACKS | 1 |
2 files changed, 21 insertions, 2 deletions
diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index e152b16..4355f18 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -587,7 +587,7 @@ printed:: ... Traceback (most recent call last): File "<stdin>", line 2, in <module> - ZeroDivisionError: int division or modulo by zero + ZeroDivisionError: division by zero The above exception was the direct cause of the following exception: @@ -606,7 +606,7 @@ attached as the new exception's :attr:`__context__` attribute:: ... Traceback (most recent call last): File "<stdin>", line 2, in <module> - ZeroDivisionError: int division or modulo by zero + ZeroDivisionError: division by zero During handling of the above exception, another exception occurred: @@ -614,9 +614,27 @@ attached as the new exception's :attr:`__context__` attribute:: File "<stdin>", line 4, in <module> RuntimeError: Something bad happened +Exception chaining can be explicitly suppressed by specifying :const:`None` in +the ``from`` clause:: + + >>> try: + ... print(1 / 0) + ... except: + ... raise RuntimeError("Something bad happened") from None + ... + Traceback (most recent call last): + File "<stdin>", line 4, in <module> + RuntimeError: Something bad happened + Additional information on exceptions can be found in section :ref:`exceptions`, and information about handling exceptions is in section :ref:`try`. +.. versionchanged:: 3.3 + :const:`None` is now permitted as ``Y`` in ``raise X from Y`` + +.. versionadded:: 3.3 + The ``__suppress_context__`` attribute to suppress automatic display of the + exception context .. _break: @@ -963,6 +963,7 @@ David Marek Doug Marien Sven Marnach Alex Martelli +Dennis Mårtensson Anthony Martin Owen Martin Sidney San Martín |