summaryrefslogtreecommitdiffstats
path: root/Lib/code.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-22 16:22:01 (GMT)
committerGitHub <noreply@github.com>2024-05-22 16:22:01 (GMT)
commita463cd8e45d6fc6ca16a59bcfeece99cf268e684 (patch)
tree48cb5d8922910e8380a7ed3d8aed8d76fadba3b3 /Lib/code.py
parenteafd633fac0c25ffdb98ffee31184eb3b4ca8b88 (diff)
downloadcpython-a463cd8e45d6fc6ca16a59bcfeece99cf268e684.zip
cpython-a463cd8e45d6fc6ca16a59bcfeece99cf268e684.tar.gz
cpython-a463cd8e45d6fc6ca16a59bcfeece99cf268e684.tar.bz2
[3.13] gh-118893: Evaluate all statements in the new REPL separately (GH-119318) (#119408)
(cherry picked from commit a3e4fec8734a304d654e4ae24a4aa2f41a7b0640) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> 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