gh-121804: always show error location for SyntaxError's in basic repl (#123202)

This commit is contained in:
Sergey B Kirpichev 2024-09-03 15:37:29 +03:00 committed by GitHub
parent ef9d54703f
commit 6822cb23c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 0 deletions

View file

@ -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):