@@ -563,10 +563,10 @@ The :keyword:`!raise` statement
563
563
.. productionlist :: python-grammar
564
564
raise_stmt: "raise" [`expression ` ["from" `expression `]]
565
565
566
- If no expressions are present, :keyword: `raise ` re-raises the last exception
567
- that was active in the current scope. If no exception is active in the current
568
- scope , a :exc: `RuntimeError ` exception is raised indicating that this is an
569
- error.
566
+ If no expressions are present, :keyword: `raise ` re-raises the
567
+ exception that is currently being handled, which is also known as the * active exception *.
568
+ If there isn't currently an active exception , a :exc: `RuntimeError ` exception is raised
569
+ indicating that this is an error.
570
570
571
571
Otherwise, :keyword: `raise ` evaluates the first expression as the exception
572
572
object. It must be either a subclass or an instance of :class: `BaseException `.
@@ -581,8 +581,8 @@ The :dfn:`type` of the exception is the exception instance's class, the
581
581
A traceback object is normally created automatically when an exception is raised
582
582
and attached to it as the :attr: `__traceback__ ` attribute, which is writable.
583
583
You can create an exception and set your own traceback in one step using the
584
- :meth: `with_traceback ` exception method (which returns the same exception
585
- instance, with its traceback set to its argument), like so::
584
+ :meth: `~BaseException. with_traceback ` exception method (which returns the
585
+ same exception instance, with its traceback set to its argument), like so::
586
586
587
587
raise Exception("foo occurred").with_traceback(tracebackobj)
588
588
@@ -614,8 +614,10 @@ exceptions will be printed::
614
614
File "<stdin>", line 4, in <module>
615
615
RuntimeError: Something bad happened
616
616
617
- A similar mechanism works implicitly if an exception is raised inside an
618
- exception handler or a :keyword: `finally ` clause: the previous exception is then
617
+ A similar mechanism works implicitly if a new exception is raised when
618
+ an exception is already being handled. An exception may be handled
619
+ when an :keyword: `except ` or :keyword: `finally ` clause, or a
620
+ :keyword: `with ` statement, is used. The previous exception is then
619
621
attached as the new exception's :attr: `__context__ ` attribute::
620
622
621
623
>>> try:
0 commit comments