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
Bare except: usages in turtle.py #71425
Comments
Will add a patch |
This patch removes all usages of "except:" in turtle.py. The tests in test_turtle.py and turtle.rst still work. |
Brett, can __file__ of imported/executed module be None, bytes or absent in 3.6? Can it be non-str? |
__file__ could be None if __spec__.origin is None. The import machinery doesn't introspect on __file__ for anything, so it won't break import if __file__ has alternative values. In general, though, normal imports will set __file__ to a string. |
The documentation says __file__ can be missing. It is missing for builtin modules (e.g. sys) and frozen modules (e.g. __hello__). |
Thanks Brett and Martin. Jelle, I think it would be safer to use "except Exception" here. "except (TypeError, ValueError):" is not enough. |
Thanks for the review and comments. This patch addresses your comments and changes the __file__-related one to catch Exception. |
Add a comment to indicate that bare exception is intentional and briefly why. |
LGTM. There is no case for bare except here. Actually it is a bug, since (in this file) a bare except can swallow KeyboardInterrupt. |
New changeset 78e5efa3dd9e by Serhiy Storchaka in branch '3.5': New changeset e9d023b7d676 by Serhiy Storchaka in branch '2.7': New changeset cd68cf41adf2 by Serhiy Storchaka in branch 'default': |
Thank you for your contribution Jelle. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: