mirror of
https://github.com/python/cpython.git
synced 2025-09-24 17:33:29 +00:00
[3.13] gh-121804: always show error location for SyntaxError's in basic repl (GH-123202) (#123631)
gh-121804: always show error location for SyntaxError's in basic repl (GH-123202)
(cherry picked from commit 6822cb23c6
)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
parent
d655c65561
commit
48941399e3
3 changed files with 46 additions and 0 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue