[issue32822] finally block doesn't re-raise exception if return statement exists inside

David Rebbe report at bugs.python.org
Sun Feb 11 17:18:17 EST 2018


New submission from David Rebbe <drebbe at intrepidcs.com>:

According to the docs:
"When an exception has occurred in the try clause and has not been handled by an except clause (or it has occurred in an except or else clause), it is re-raised after the finally clause has been executed."
https://docs.python.org/2/tutorial/errors.html#defining-clean-up-actions

This seems to not be the case if return inside a finally block, the exception needing to be thrown looks like its tossed out.

I'm not sure if this is intended behavior and the docs need to be updated or python isn't doing the correct behavior.



Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

----------
components: Interpreter Core
files: finally_test.py
messages: 312014
nosy: David Rebbe
priority: normal
severity: normal
status: open
title: finally block doesn't re-raise exception if return statement exists inside
type: behavior
versions: Python 3.4
Added file: https://bugs.python.org/file47438/finally_test.py

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


More information about the Python-bugs-list mailing list