mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-118893: Evaluate all statements in the new REPL separately (#119318)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
9fa206aaec
commit
a3e4fec873
5 changed files with 128 additions and 9 deletions
|
@ -94,7 +94,7 @@ class InteractiveInterpreter:
|
|||
except:
|
||||
self.showtraceback()
|
||||
|
||||
def showsyntaxerror(self, filename=None):
|
||||
def showsyntaxerror(self, filename=None, **kwargs):
|
||||
"""Display the syntax error that just occurred.
|
||||
|
||||
This doesn't display a stack trace because there isn't one.
|
||||
|
@ -106,6 +106,7 @@ class InteractiveInterpreter:
|
|||
The output is written by self.write(), below.
|
||||
|
||||
"""
|
||||
colorize = kwargs.pop('colorize', False)
|
||||
type, value, tb = sys.exc_info()
|
||||
sys.last_exc = value
|
||||
sys.last_type = type
|
||||
|
@ -123,7 +124,7 @@ class InteractiveInterpreter:
|
|||
value = SyntaxError(msg, (filename, lineno, offset, line))
|
||||
sys.last_exc = sys.last_value = value
|
||||
if sys.excepthook is sys.__excepthook__:
|
||||
lines = traceback.format_exception_only(type, value)
|
||||
lines = traceback.format_exception_only(type, value, colorize=colorize)
|
||||
self.write(''.join(lines))
|
||||
else:
|
||||
# If someone has set sys.excepthook, we let that take precedence
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue