diff options
author | Michael Droettboom <mdboom@gmail.com> | 2022-09-06 19:12:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-07 00:12:16 +0100 |
commit | 05692c67c51b78a5a5a7bb61d646519025e38015 (patch) | |
tree | 1fe2f031c0d77bcfdd09d1acb20a752d176f8047 /Lib/test/test_source_encoding.py | |
parent | 67444902a0f10419a557d0a2d3b8675c31b075a9 (diff) | |
download | cpython-05692c67c51b78a5a5a7bb61d646519025e38015.tar.gz cpython-05692c67c51b78a5a5a7bb61d646519025e38015.zip |
gh-96611: Fix error message for invalid UTF-8 in mid-multiline string (#96623)
Diffstat (limited to 'Lib/test/test_source_encoding.py')
-rw-r--r-- | Lib/test/test_source_encoding.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_source_encoding.py b/Lib/test/test_source_encoding.py index 8e68b4eae33..feaff4770f7 100644 --- a/Lib/test/test_source_encoding.py +++ b/Lib/test/test_source_encoding.py @@ -147,6 +147,18 @@ class MiscSourceEncodingTest(unittest.TestCase): self.assertTrue(c.exception.args[0].startswith(expected), msg=c.exception.args[0]) + def test_file_parse_error_multiline(self): + # gh96611: + with open(TESTFN, "wb") as fd: + fd.write(b'print("""\n\xb1""")\n') + + try: + retcode, stdout, stderr = script_helper.assert_python_failure(TESTFN) + + self.assertGreater(retcode, 0) + self.assertIn(b"Non-UTF-8 code starting with '\\xb1'", stderr) + finally: + os.unlink(TESTFN) class AbstractSourceEncodingTest: |