diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2023-05-04 12:26:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 12:26:23 (GMT) |
commit | ef0df5284f929719b2ef3955b1b569ade0a5193c (patch) | |
tree | a3042bd8ea3e8f877f59222f8695f5aca4a4470d /Lib/test/test_cmd_line_script.py | |
parent | 55d50d147c953fab37b273bca9ab010f40e067d3 (diff) | |
download | cpython-ef0df5284f929719b2ef3955b1b569ade0a5193c.zip cpython-ef0df5284f929719b2ef3955b1b569ade0a5193c.tar.gz cpython-ef0df5284f929719b2ef3955b1b569ade0a5193c.tar.bz2 |
gh-97556: Raise null bytes syntax error upon null in multiline string (GH-104136)
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r-- | Lib/test/test_cmd_line_script.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index d98e238..8bf2993 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -669,6 +669,19 @@ class CmdLineTest(unittest.TestCase): ], ) + def test_syntaxerror_null_bytes_in_multiline_string(self): + scripts = ["\n'''\nmultilinestring\0\n'''", "\nf'''\nmultilinestring\0\n'''"] # Both normal and f-strings + with os_helper.temp_dir() as script_dir: + for script in scripts: + script_name = _make_test_script(script_dir, 'script', script) + _, _, stderr = assert_python_failure(script_name) + self.assertEqual( + stderr.splitlines()[-2:], + [ b" multilinestring", + b'SyntaxError: source code cannot contain null bytes' + ] + ) + def test_consistent_sys_path_for_direct_execution(self): # This test case ensures that the following all give the same # sys.path configuration: |