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 in finally swallows exceptions #816

Open
2 tasks done
iritkatriel opened this issue Oct 29, 2024 · 1 comment
Open
2 tasks done

return in finally swallows exceptions #816

iritkatriel opened this issue Oct 29, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@iritkatriel
Copy link

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

AnyIO version

mater branch

Python version

NA

What happened?

In

return result
there is a return statement in a finally block, which would swallow any in-flight exception.

This means that if an unhandled exception (including a BaseException such as KeyboardInterrupt) is raised from the try body, it will not propagate on as expected.

If the intention is to suppress all exceptions, I would propose to make this clear by using except BaseException.

See also https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions.

How can we reproduce the bug?

NA

@iritkatriel iritkatriel added the bug Something isn't working label Oct 29, 2024
@agronholm
Copy link
Owner

Note to self: this can be found in anyio.from_thread._BlockingAsyncContextManager.run_async_cm().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants