8000 Don't use bare except statements by timhoffm · Pull Request #11995 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Don't use bare except statements #11995

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

Merged
merged 1 commit into from
Sep 2, 2018
Merged

Conversation

timhoffm
Copy link
Member
@timhoffm timhoffm commented Sep 1, 2018

PR Summary

We don't want to catch KeyboardInterrupt and SystemExit exceptions in these cases.

https://lgtm.com/rules/6780080/

@timhoffm timhoffm changed the title Don't use bare execpt statements Don't use bare except statements Sep 1, 2018
@jklymak jklymak merged commit 90037f4 into matplotlib:master Sep 2, 2018
@timhoffm timhoffm deleted the bare-except branch September 2, 2018 00:36
@QuLogic QuLogic added this to the v3.1 milestone Sep 2, 2018
@@ -1407,7 +1407,7 @@ def _update_enter_leave(self):
try:
if last.inaxes is not None:
last.canvas.callbacks.process('axes_leave_event', last)
except:
except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure about this one given the comment below it? Raising exceptions in GUI event loops can go very wrong very quickly (aka Qt exits the process!).

Copy link
Member Author
@timhoffm timhoffm Sep 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That try-except block is only there to catch exceptions from the callbacks. KeyboardInterrupt and SystemExit can happen anywhere and Qt has to cope with this somehow. I don't see why we should catch these events if they happen by chance while the canvas callbacks are processed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 That comment almost certainly dates to when anything could be raised as as exception.

@tacaswell
Copy link
Member

Sorry for the after-the-fact review.

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 this pull request may close these issues.

5 participants
0