@@ -587,7 +587,7 @@ printed::
587
587
...
588
588
Traceback (most recent call last):
589
589
File "<stdin>", line 2, in <module>
590
- ZeroDivisionError: int division or modulo by zero
590
+ ZeroDivisionError: division by zero
591
591
592
592
The above exception was the direct cause of the following exception:
593
593
@@ -606,17 +606,35 @@ attached as the new exception's :attr:`__context__` attribute::
606
606
...
607
607
Traceback (most recent call last):
608
608
File "<stdin>", line 2, in <module>
609
- ZeroDivisionError: int division or modulo by zero
609
+ ZeroDivisionError: division by zero
610
610
611
611
During handling of the above exception, another exception occurred:
612
612
613
613
Traceback (most recent call last):
614
614
File "<stdin>", line 4, in <module>
615
615
RuntimeError: Something bad happened
616
616
617
+ Exception chaining can be explicitly suppressed by specifying :const: `None ` in
618
+ the ``from `` clause::
619
+
620
+ >>> try:
621
+ ... print(1 / 0)
622
+ ... except:
623
+ ... raise RuntimeError("Something bad happened") from None
624
+ ...
625
+ Traceback (most recent call last):
626
+ File "<stdin>", line 4, in <module>
627
+ RuntimeError: Something bad happened
628
+
617
629
Additional information on exceptions can be found in section :ref: `exceptions `,
618
630
and information about handling exceptions is in section :ref: `try `.
619
631
632
+ .. versionchanged :: 3.3
633
+ :const: `None ` is now permitted as ``Y `` in ``raise X from Y ``
634
+
635
+ .. versionadded :: 3.3
636
+ The ``__suppress_context__ `` attribute to suppress automatic display of the
637
+ exception context
620
638
621
639
.. _break :
622
640
0 commit comments