Skip to content

Commit 0679a73

Browse files
author
Skip Montanaro
committed
remove unqualified excepts - catch ImportError when trying to import
readline and get rid of string exception fallback when showing syntax errors. see bug 411881
1 parent 0897f0c commit 0679a73

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Lib/code.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,7 @@ def showsyntaxerror(self, filename=None):
133133
pass
134134
else:
135135
# Stuff in the right filename
136-
try:
137-
# Assume SyntaxError is a class exception
138-
value = SyntaxError(msg, (filename, lineno, offset, line))
139-
except:
140-
# If that failed, assume SyntaxError is a string
141-
value = msg, (filename, lineno, offset, line)
136+
value = SyntaxError(msg, (filename, lineno, offset, line))
142137
sys.last_value = value
143138
list = traceback.format_exception_only(type, value)
144139
map(self.write, list)
@@ -302,7 +297,7 @@ def interact(banner=None, readfunc=None, local=None):
302297
else:
303298
try:
304299
import readline
305-
except:
300+
except ImportError:
306301
pass
307302
console.interact(banner)
308303

0 commit comments

Comments
 (0)