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 #1731

Open
iritkatriel opened this issue Oct 25, 2024 · 0 comments
Open

return in finally swallows exceptions #1731

iritkatriel opened this issue Oct 25, 2024 · 0 comments
Labels
Bug Something isn't working Triage 👀

Comments

@iritkatriel
Copy link

iritkatriel commented Oct 25, 2024

In

return os.path.join(target_path, "edr.log")
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, or any exception is raised from an except: clause, it will not propagate on as expected.

If it was the intention to swallow all exceptions here, I would suggest to do this explicitly with except BaseExceptions: to make the intention clear.

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

@iritkatriel iritkatriel added Bug Something isn't working Triage 👀 labels Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Triage 👀
Projects
None yet
Development

No branches or pull requests

1 participant