summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl/console.py
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-08-19 19:01:58 (GMT)
committerGitHub <noreply@github.com>2024-08-19 19:01:58 (GMT)
commitc8f4069ab1602a1f67239fef0e11cc3e72c0045d (patch)
tree958e6704cd0102ea848a511fec9f7d8f50cc9dd7 /Lib/_pyrepl/console.py
parent21399a096302ea577efd9a12c2f08b4458d095bd (diff)
downloadcpython-c8f4069ab1602a1f67239fef0e11cc3e72c0045d.zip
cpython-c8f4069ab1602a1f67239fef0e11cc3e72c0045d.tar.gz
cpython-c8f4069ab1602a1f67239fef0e11cc3e72c0045d.tar.bz2
[3.13] gh-121804: Always show error location for SyntaxError's in new repl (GH-121886) (#123148)
(cherry picked from commit 354d55eb1fa40f272419aa6459ee5d2c4804c8ea)
Diffstat (limited to 'Lib/_pyrepl/console.py')
-rw-r--r--Lib/_pyrepl/console.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/_pyrepl/console.py b/Lib/_pyrepl/console.py
index a8d3f52..4319343 100644
--- a/Lib/_pyrepl/console.py
+++ b/Lib/_pyrepl/console.py
@@ -161,8 +161,8 @@ class InteractiveColoredConsole(code.InteractiveConsole):
super().__init__(locals=locals, filename=filename, local_exit=local_exit) # type: ignore[call-arg]
self.can_colorize = _colorize.can_colorize()
- def showsyntaxerror(self, filename=None):
- super().showsyntaxerror(colorize=self.can_colorize)
+ def showsyntaxerror(self, filename=None, **kwargs):
+ super().showsyntaxerror(colorize=self.can_colorize, **kwargs)
def showtraceback(self):
super().showtraceback(colorize=self.can_colorize)
@@ -171,7 +171,7 @@ class InteractiveColoredConsole(code.InteractiveConsole):
try:
tree = ast.parse(source)
except (SyntaxError, OverflowError, ValueError):
- self.showsyntaxerror(filename)
+ self.showsyntaxerror(filename, source=source)
return False
if tree.body:
*_, last_stmt = tree.body
@@ -188,10 +188,10 @@ class InteractiveColoredConsole(code.InteractiveConsole):
f"Try the asyncio REPL ({python} -m asyncio) to use"
f" top-level 'await' and run background asyncio tasks."
)
- self.showsyntaxerror(filename)
+ self.showsyntaxerror(filename, source=source)
return False
except (OverflowError, ValueError):
- self.showsyntaxerror(filename)
+ self.showsyntaxerror(filename, source=source)
return False
if code is None: