Skip to content

Commit b086c8a

Browse files
andresdelfinomiss-islington
authored andcommitted
bpo-33699: Describe try's else clause with the rest of the try clause (pythonGH-7252)
https://bugs.python.org/issue33699
1 parent 76e8fd7 commit b086c8a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Doc/reference/compound_stmts.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,11 @@ from a function that handled an exception.
314314
statement: break
315315
statement: continue
316316

317-
The optional :keyword:`else` clause is executed if and when control flows off
318-
the end of the :keyword:`try` clause. [#]_ Exceptions in the :keyword:`else`
319-
clause are not handled by the preceding :keyword:`except` clauses.
317+
The optional :keyword:`else` clause is executed if the control flow leaves the
318+
:keyword:`try` suite, no exception was raised, and no :keyword:`return`,
319+
:keyword:`continue`, or :keyword:`break` statement was executed. Exceptions in
320+
the :keyword:`else` clause are not handled by the preceding :keyword:`except`
321+
clauses.
320322

321323
.. index:: keyword: finally
322324

@@ -847,10 +849,6 @@ body of a coroutine function.
847849
there is a :keyword:`finally` clause which happens to raise another
848850
exception. That new exception causes the old one to be lost.
849851
850-
.. [#] Currently, control "flows off the end" except in the case of an exception
851-
or the execution of a :keyword:`return`, :keyword:`continue`, or
852-
:keyword:`break` statement.
853-
854852
.. [#] A string literal appearing as the first statement in the function body is
855853
transformed into the function's ``__doc__`` attribute and therefore the
856854
function's :term:`docstring`.

0 commit comments

Comments
 (0)