mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
remove unqualified excepts - catch ImportError when trying to import
readline and get rid of string exception fallback when showing syntax errors. see bug 411881
This commit is contained in:
parent
0897f0c4f8
commit
0679a73c0e
1 changed files with 2 additions and 7 deletions
|
@ -133,12 +133,7 @@ class InteractiveInterpreter:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# Stuff in the right filename
|
# Stuff in the right filename
|
||||||
try:
|
value = SyntaxError(msg, (filename, lineno, offset, line))
|
||||||
# Assume SyntaxError is a class exception
|
|
||||||
value = SyntaxError(msg, (filename, lineno, offset, line))
|
|
||||||
except:
|
|
||||||
# If that failed, assume SyntaxError is a string
|
|
||||||
value = msg, (filename, lineno, offset, line)
|
|
||||||
sys.last_value = value
|
sys.last_value = value
|
||||||
list = traceback.format_exception_only(type, value)
|
list = traceback.format_exception_only(type, value)
|
||||||
map(self.write, list)
|
map(self.write, list)
|
||||||
|
@ -302,7 +297,7 @@ def interact(banner=None, readfunc=None, local=None):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
import readline
|
import readline
|
||||||
except:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
console.interact(banner)
|
console.interact(banner)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue