This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Bare except: usages in turtle.py
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: JelleZijlstra, brett.cannon, martin.panter, python-dev, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2016-06-06 00:38 by JelleZijlstra, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue27238.patch JelleZijlstra, 2016-06-06 13:49 review
issue27238-cr.patch JelleZijlstra, 2016-06-08 05:01 revised patch review
Messages (11)
msg267493 - (view) Author: Jelle Zijlstra (JelleZijlstra) * (Python committer) Date: 2016-06-06 00:38
Will add a patch
msg267528 - (view) Author: Jelle Zijlstra (JelleZijlstra) * (Python committer) Date: 2016-06-06 13:49
This patch removes all usages of "except:" in turtle.py. The tests in test_turtle.py and turtle.rst still work.
msg267556 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-06 20:52
Brett, can __file__ of imported/executed module be None, bytes or absent in 3.6? Can it be non-str?
msg267562 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-06-06 21:41
__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.
msg267570 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-06-06 23:13
The documentation says __file__ can be missing. It is missing for builtin modules (e.g. sys) and frozen modules (e.g. __hello__).
msg267592 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-07 04:54
Thanks Brett and Martin.

Jelle, I think it would be safer to use "except Exception" here. "except (TypeError, ValueError):" is not enough.
msg267779 - (view) Author: Jelle Zijlstra (JelleZijlstra) * (Python committer) Date: 2016-06-08 05:01
Thanks for the review and comments. This patch addresses your comments and changes the __file__-related one to catch Exception.
msg268167 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-10 23:30
Add a comment to indicate that bare exception is intentional and briefly why.
msg268583 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-14 19:40
LGTM.

There is no case for bare except here. Actually it is a bug, since (in this file) a bare except can swallow KeyboardInterrupt.
msg268584 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-14 19:54
New changeset 78e5efa3dd9e by Serhiy Storchaka in branch '3.5':
Issue #27238: Got rid of bare excepts in the turtle module.  Original patch
https://hg.python.org/cpython/rev/78e5efa3dd9e

New changeset e9d023b7d676 by Serhiy Storchaka in branch '2.7':
Issue #27238: Got rid of bare excepts in the turtle module.  Original patch
https://hg.python.org/cpython/rev/e9d023b7d676

New changeset cd68cf41adf2 by Serhiy Storchaka in branch 'default':
Issue #27238: Got rid of bare excepts in the turtle module.  Original patch
https://hg.python.org/cpython/rev/cd68cf41adf2
msg268585 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-14 19:55
Thank you for your contribution Jelle.
History
Date User Action Args
2022-04-11 14:58:32adminsetgithub: 71425
2016-06-14 19:55:39serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg268585

stage: commit review -> resolved
2016-06-14 19:54:30python-devsetnosy: + python-dev
messages: + msg268584
2016-06-14 19:40:29serhiy.storchakasetversions: + Python 2.7, Python 3.5
messages: + msg268583

assignee: JelleZijlstra -> serhiy.storchaka
type: enhancement -> behavior
stage: patch review -> commit review
2016-06-10 23:30:28terry.reedysetnosy: + terry.reedy
messages: + msg268167
2016-06-08 05:01:33JelleZijlstrasetfiles: + issue27238-cr.patch

messages: + msg267779
2016-06-07 04:54:39serhiy.storchakasetmessages: + msg267592
2016-06-06 23:13:40martin.pantersetnosy: + martin.panter
messages: + msg267570
2016-06-06 21:41:56brett.cannonsetmessages: + msg267562
2016-06-06 20:52:15serhiy.storchakasetnosy: + brett.cannon
messages: + msg267556
2016-06-06 14:22:13serhiy.storchakasettype: enhancement
stage: patch review
2016-06-06 13:49:06JelleZijlstrasetfiles: + issue27238.patch
keywords: + patch
messages: + msg267528
2016-06-06 00:38:06JelleZijlstracreate