Issue 27238: Bare except: usages in turtle.py
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) * ![]() |
Date: 2016-06-06 00:38 | |
Will add a patch |
|||
| msg267528 - (view) | Author: Jelle Zijlstra (JelleZijlstra) * ![]() |
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) * ![]() |
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) * ![]() |
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) * ![]() |
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) * ![]() |
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) * ![]() |
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) * ![]() |
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) * ![]() |
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) ![]() |
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) * ![]() |
Date: 2016-06-14 19:55 | |
Thank you for your contribution Jelle. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:32 | admin | set | github: 71425 |
| 2016-06-14 19:55:39 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: + msg268585 stage: commit review -> resolved |
| 2016-06-14 19:54:30 | python-dev | set | nosy:
+ python-dev messages: + msg268584 |
| 2016-06-14 19:40:29 | serhiy.storchaka | set | versions:
+ Python 2.7, Python 3.5 messages: + msg268583 assignee: JelleZijlstra -> serhiy.storchaka |
| 2016-06-10 23:30:28 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg268167 |
| 2016-06-08 05:01:33 | JelleZijlstra | set | files:
+ issue27238-cr.patch messages: + msg267779 |
| 2016-06-07 04:54:39 | serhiy.storchaka | set | messages: + msg267592 |
| 2016-06-06 23:13:40 | martin.panter | set | nosy:
+ martin.panter messages: + msg267570 |
| 2016-06-06 21:41:56 | brett.cannon | set | messages: + msg267562 |
| 2016-06-06 20:52:15 | serhiy.storchaka | set | nosy:
+ brett.cannon messages: + msg267556 |
| 2016-06-06 14:22:13 | serhiy.storchaka | set | type: enhancement stage: patch review |
| 2016-06-06 13:49:06 | JelleZijlstra | set | files:
+ issue27238.patch keywords: + patch messages: + msg267528 |
| 2016-06-06 00:38:06 | JelleZijlstra | create | |

