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

Is break in finally intentional? #445

Closed
asvetlov opened this issue Jul 27, 2015 · 2 comments
Closed

Is break in finally intentional? #445

asvetlov opened this issue Jul 27, 2015 · 2 comments
Labels

Comments

@asvetlov
Copy link
Member

In low-level server code I see break statements inside finally blocks like https://github.com/KeepSafe/aiohttp/blob/master/aiohttp/server.py#L290

It looks suspicious: break inside finally block discards saved exception (see https://docs.python.org/3.5/reference/simple_stmts.html#break).
I believe return should be used instead, it does the same in the case (stop reading incoming data) but it is show the intention much more explicitly.

@fafhrd91 you are author of these lines. Do you remember the motivation for break statement?

@fafhrd91
Copy link
Member

I do not really remember, but good catch let's replace with returns

Sent from my iPhone

On Jul 27, 2015, at 7:53 AM, Andrew Svetlov [email protected] wrote:

In low-level server code I see break statements inside finally blocks like https://github.com/KeepSafe/aiohttp/blob/master/aiohttp/server.py#L290

It looks suspicious: break inside finally block discards saved exception (see https://docs.python.org/3.5/reference/simple_stmts.html#break).
I believe return should be used instead, it does the same in the case (stop reading incoming data) but it is shows the intention much more explicitly.

@fafhrd91 you are author of these lines. Do you remember the motivation for break statement?


Reply to this email directly or view it on GitHub.

@asvetlov asvetlov changed the title Is break in finally intentional Is break in finally intentional? Jul 27, 2015
asvetlov added a commit that referenced this issue Jul 27, 2015
Fix #445: replace break with return on server connection cleanups
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants