[issue35916] 3.6.5 try/except/else/finally block executes code with typos, no errors

SilentGhost report at bugs.python.org
Wed Feb 6 11:26:22 EST 2019


SilentGhost <ghost.adh at runbox.com> added the comment:

This seem to be the exactly documented behaviour. From https://docs.python.org/3.8/reference/compound_stmts.html#the-try-statement

If finally is present, it specifies a ‘cleanup’ handler. The try clause is executed, including any except and else clauses. If an exception occurs in any of the clauses and is not handled, the exception is temporarily saved. The finally clause is executed. If there is a saved exception it is re-raised at the end of the finally clause. If the finally clause raises another exception, the saved exception is set as the context of the new exception. If the finally clause executes a return, break or continue statement, the saved exception is discarded.

----------
nosy: +SilentGhost
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35916>
_______________________________________


More information about the Python-bugs-list mailing list