Skip to content

Commit 44212ec

Browse files
asottilepablogsal
authored andcommitted
Add additional test for multi-line SyntaxError (GH-15003)
1 parent 5b94f35 commit 44212ec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_cmd_line_script.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,22 @@ def test_syntaxerror_multi_line_fstring(self):
627627
],
628628
)
629629

630+
def test_syntaxerror_invalid_escape_sequence_multi_line(self):
631+
script = 'foo = """\\q\n"""\n'
632+
with support.temp_dir() as script_dir:
633+
script_name = _make_test_script(script_dir, 'script', script)
634+
exitcode, stdout, stderr = assert_python_failure(
635+
'-Werror', script_name,
636+
)
637+
self.assertEqual(
638+
stderr.splitlines()[-3:],
639+
[
640+
b' foo = """\\q',
641+
b' ^',
642+
b'SyntaxError: invalid escape sequence \\q',
643+
],
644+
)
645+
630646
def test_consistent_sys_path_for_direct_execution(self):
631647
# This test case ensures that the following all give the same
632648
# sys.path configuration:

0 commit comments

Comments
 (0)