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. #2630

Closed
iritkatriel opened this issue Oct 25, 2024 · 1 comment · Fixed by #2639
Closed

return in finally swallows exceptions. #2630

iritkatriel opened this issue Oct 25, 2024 · 1 comment · Fixed by #2639

Comments

@iritkatriel
Copy link

In

return super().Destroy(*args, **kwargs)

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.

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

@komoto48g
Copy link
Contributor

komoto48g commented Nov 1, 2024

@swt2c, I commented #2373 and proposed finally return.
But it seems fine even if it doesn't return a bool value, as it can close without issues. If I understand correctly, this is because wx.lib.agw.flatmenu.FlatMenu is a subclass of wx.PopupWindow, not wx.TopLevelWindow.
So to keep the code healthy, I'd make a PR like this:

     def Destroy(self, *args, **kwargs):
        self.Clear()
        return super().Destroy(*args, **kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants