summaryrefslogtreecommitdiffstats
path: root/Lib/code.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-05-21 23:16:56 (GMT)
committerGitHub <noreply@github.com>2024-05-21 23:16:56 (GMT)
commita3e4fec8734a304d654e4ae24a4aa2f41a7b0640 (patch)
treea152e54e9dad1a39e40b2bfd5f2b167576dda446 /Lib/code.py
parent9fa206aaeccc979a4bd03852ba38c045294a3d6f (diff)
downloadcpython-a3e4fec8734a304d654e4ae24a4aa2f41a7b0640.zip
cpython-a3e4fec8734a304d654e4ae24a4aa2f41a7b0640.tar.gz
cpython-a3e4fec8734a304d654e4ae24a4aa2f41a7b0640.tar.bz2
gh-118893: Evaluate all statements in the new REPL separately (#119318)
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/code.py')
-rw-r--r--Lib/code.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/code.py b/Lib/code.py
index 0c2fd29..b93902c 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -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