Skip to content

Commit 0c40b6c

Browse files
committed
doctest doesn't like it
1 parent c95a195 commit 0c40b6c

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

Doc/reference/compound_stmts.rst

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -420,16 +420,15 @@ is executed. If there is a saved exception it is re-raised at the end of the
420420
:keyword:`!finally` clause. If the :keyword:`!finally` clause raises another
421421
exception, the saved exception is set as the context of the new exception.
422422
If the :keyword:`!finally` clause executes a :keyword:`return`, :keyword:`break`
423-
or :keyword:`continue` statement, the saved exception is discarded.
423+
or :keyword:`continue` statement, the saved exception is discarded. For example,
424+
this function returns 42.
424425

425-
>>> def f():
426-
... try:
427-
... 1/0
428-
... finally:
429-
... return 42
430-
...
431-
>>> f()
432-
42
426+
.. code::
427+
def f():
428+
try:
429+
1/0
430+
finally:
431+
return 42
433432
434433
The exception information is not available to the program during execution of
435434
the :keyword:`!finally` clause.
@@ -446,16 +445,14 @@ statement, the :keyword:`!finally` clause is also executed 'on the way out.'
446445
The return value of a function is determined by the last :keyword:`return`
447446
statement executed. Since the :keyword:`!finally` clause always executes, a
448447
:keyword:`!return` statement executed in the :keyword:`!finally` clause will
449-
always be the last one executed::
448+
always be the last one executed. The following function returns 'finally'.
450449

451-
>>> def foo():
452-
... try:
453-
... return 'try'
454-
... finally:
455-
... return 'finally'
456-
...
457-
>>> foo()
458-
'finally'
450+
.. code::
451+
def foo():
452+
try:
453+
return 'try'
454+
finally:
455+
return 'finally'
459456
460457
.. versionchanged:: 3.8
461458
Prior to Python 3.8, a :keyword:`continue` statement was illegal in the

0 commit comments

Comments
 (0)