-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
IDLE - remove all bare excepts #59518
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
Comments
There are a lot of bare exceptions in IDLE. Here's the output of "grep -n 'except:' *.py" AutoComplete.py:184: except: Slowly, these exceptions should be refined to include the exact exception being caught. |
And possibly change the except clause. The except clause at PyShell 1245 was 'pass', which masked the issue of bpo-13532 and was changed to 'raise' to effectively remove the try: except: to make the unknown problem more visible. It should perhaps be really removed if and when all calls to PyShell.write(s) are properly guarded to make sure 's' is writable. |
Line 1245 is part of this code (in time, these line numbers will change.)
The delegator chain that sits between OutputWindow.write and the Tkinter text.insert method can raise any error. (The ColorDelegator would raise a TypeError when "s" was not a string). I'd rather not replace this with "except Exception:" since the delegators should catch their own errors. I suggest removing this try/catch block. |
Also, bpo-13582 will become relevant on Windows since modifying the bare excepts may let uncaught exceptions be written to stderr, causing IDLE to crash. |
RA's patch for bpo-16261 suggests diff -r b76d2d8db81f Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py Mon Dec 17 13:43:14 2012 +0530
+++ b/Lib/idlelib/PyShell.py Wed Jan 09 19:10:26 2013 +0530
@@ -152,7 +152,7 @@
lineno = int(float(text.index("insert")))
try:
self.breakpoints.remove(lineno)
- except:
+ except ValueError:
pass
text.tag_remove("BREAK", "insert linestart",\
"insert lineend +1char") |
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: