aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/code.py
diff options
context:
space:
mode:
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 0c2fd2963b2..b93902ccf54 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