8000 gh-67224: Show source lines in tracebacks when using the -c option when running Python by pablogsal · Pull Request #111200 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-67224: Show source lines in tracebacks when using the -c option when running Python #111200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Lib/test/test_cmd_line_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,17 @@ def test_source_lines_are_shown_when_running_source(self):
b'ZeroDivisionError: division by zero']
self.assertEqual(stderr.splitlines(), expected_lines)

def test_syntaxerror_does_not_crash(self):
script = "nonlocal x\n"
with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script', script)
exitcode, stdout, stderr = assert_python_failure(script_name)
text = io.TextIOWrapper(io.BytesIO(stderr), 'ascii').read()
# It used to crash in https://github.com/python/cpython/issues/111132
self.assertTrue(text.endswith(
'SyntaxError: nonlocal declaration not allowed at module level\n',
), text)

def test_consistent_sys_path_for_direct_execution(self):
# This test case ensures that the following all give the same
# sys.path configuration:
Expand Down
0