@@ -195,26 +195,25 @@ \section{The \keyword{try} statement\label{try}}
195195code for a group of statements:
196196
197197\begin {productionlist }
198- \production {try_stmt}
199- {\token {try_exc_stmt} | \token {try_fin_stmt}}
200- \production {try_exc_stmt}
198+ \production {try_stmt} {try1_stmt | try2_stmt}
199+ \production {try1_stmt}
201200 {"try" ":" \token {suite}}
202201 \productioncont {("except" [\token {expression}
203202 ["," \token {target}]] ":" \token {suite})+}
204203 \productioncont {["else" ":" \token {suite}]}
205- \production {try_fin_stmt}
206- {"try" ":" \token {suite}
207- "finally" ":" \token {suite}}
204+ \productioncont {["finally" ":" \token {suite}]}
205+ \production {try2_stmt}
206+ {"try" ":" \token {suite}}
207+ \productioncont {"finally" ":" \token {suite}}
208208\end {productionlist }
209209
210- There are two forms of \keyword {try} statement:
211- \keyword {try}...\keyword {except} and
212- \keyword {try}...\keyword {finally}. These forms cannot be mixed (but
213- they can be nested in each other).
210+ \versionchanged [In previous versions of Python,
211+ \keyword {try}...\keyword {except}... \keyword {finally} did not work.
212+ \keyword {try}...\keyword {except} had to be nested in
213+ \keyword {try}... \keyword {finally}]{2.5}
214214
215- The \keyword {try}...\keyword {except} form specifies one or more
216- exception handlers
217- (the \keyword {except} clauses). When no exception occurs in the
215+ The \keyword {except} clause(s) specify one or more exception handlers.
216+ When no exception occurs in the
218217\keyword {try} clause, no exception handler is executed. When an
219218exception occurs in the \keyword {try} suite, a search for an exception
220219handler is started. This search inspects the except clauses in turn until
@@ -232,6 +231,8 @@ \section{The \keyword{try} statement\label{try}}
232231
233232If no except clause matches the exception, the search for an exception
234233handler continues in the surrounding code and on the invocation stack.
234+ \footnote {The exception is propogated to the invocation stack only if
235+ there is no \keyword {finally} clause that negates the exception.}
235236
236237If the evaluation of an expression in the header of an except clause
237238raises an exception, the original search for a handler is canceled
@@ -277,12 +278,13 @@ \section{The \keyword{try} statement\label{try}}
277278\stindex {break}
278279\stindex {continue}
279280
280- The \keyword {try}...\keyword {finally} form specifies a `cleanup' handler. The
281- \keyword {try} clause is executed. When no exception occurs, the
282- \keyword {finally} clause is executed. When an exception occurs in the
283- \keyword {try} clause, the exception is temporarily saved, the
284- \keyword {finally} clause is executed, and then the saved exception is
285- re-raised. If the \keyword {finally} clause raises another exception or
281+ If \keyword {finally} is present, it specifies a `cleanup' handler. The
282+ \keyword {try} clause is executed, including any \keyword {except} and
283+ \keyword {else} clauses. If an exception occurs in any of the clauses
284+ and is not handled, the exception is temporarily saved. The
285+ \keyword {finally} clause is executed. If there is a saved exception,
286+ it is re-raised at the end of the \keyword {finally} clause.
287+ If the \keyword {finally} clause raises another exception or
286288executes a \keyword {return} or \keyword {break} statement, the saved
287289exception is lost. A \keyword {continue} statement is illegal in the
288290\keyword {finally} clause. (The reason is a problem with the current
0 commit comments