summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-09-03 12:37:29 (GMT)
committerGitHub <noreply@github.com>2024-09-03 12:37:29 (GMT)
commit6822cb23c62032381971d8a47fd41d1e98710a8c (patch)
treeda368dc55e3db0716a81df0c2644985a937e4146 /Lib/test
parentef9d54703f1f21d2fde2fe3ef49d4cf7c8b38f06 (diff)
downloadcpython-6822cb23c62032381971d8a47fd41d1e98710a8c.zip
cpython-6822cb23c62032381971d8a47fd41d1e98710a8c.tar.gz
cpython-6822cb23c62032381971d8a47fd41d1e98710a8c.tar.bz2
gh-121804: always show error location for SyntaxError's in basic repl (#123202)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_repl.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py
index 0b93862..363808c 100644
--- a/Lib/test/test_repl.py
+++ b/Lib/test/test_repl.py
@@ -187,6 +187,19 @@ class TestInteractiveInterpreter(unittest.TestCase):
]
self.assertEqual(traceback_lines, expected_lines)
+ def test_runsource_show_syntax_error_location(self):
+ user_input = dedent("""def f(x, x): ...
+ """)
+ p = spawn_repl()
+ p.stdin.write(user_input)
+ output = kill_python(p)
+ expected_lines = [
+ ' def f(x, x): ...',
+ ' ^',
+ "SyntaxError: duplicate argument 'x' in function definition"
+ ]
+ self.assertEqual(output.splitlines()[4:-1], expected_lines)
+
def test_interactive_source_is_in_linecache(self):
user_input = dedent("""
def foo(x):