Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return or break statement in a finally block #73

Closed
koddo opened this issue Feb 27, 2018 · 3 comments
Closed

return or break statement in a finally block #73

koddo opened this issue Feb 27, 2018 · 3 comments
Milestone

Comments

@koddo
Copy link

koddo commented Feb 27, 2018

Hello. What do you think, is the following a wat?

https://docs.python.org/3/reference/compound_stmts.html#the-try-statement:

If an exception occurs in any of the clauses and is not handled, the exception is temporarily saved. ... If the finally clause executes a return or break statement, the saved exception is discarded.

Example:

while True:
    try:
        1/0
    except Exception:
        raise
    finally:
        break     # discards the exception

print('hell')     # it does print indeed
@satwikkansal
Copy link
Owner

Hey @koddo

That's interesting. Thanks for sharing it. I'd be adding this in the next iteration (or you can submit a PR if you like)

@shashank1094
Copy link

Hell is getting printed. I am using Python 3.6.4.

@satwikkansal satwikkansal added this to the 3.0 milestone Dec 4, 2018
@satwikkansal
Copy link
Owner

Added to the collection, thanks again!

muscliary pushed a commit to muscliary/wtfpython that referenced this issue Sep 12, 2023
muscliary pushed a commit to muscliary/wtfpython that referenced this issue Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants