diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-09-06 23:40:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-06 23:40:17 (GMT) |
commit | bb0dab5c48de0fabec6b3eb27316394e3b65ee2c (patch) | |
tree | 0d85aa6ab4846f9038e572ceb4665d6ddefa15ad /Lib/test/test_source_encoding.py | |
parent | a389fdb0958746c4c4ee8849a71a276516f33776 (diff) | |
download | cpython-bb0dab5c48de0fabec6b3eb27316394e3b65ee2c.zip cpython-bb0dab5c48de0fabec6b3eb27316394e3b65ee2c.tar.gz cpython-bb0dab5c48de0fabec6b3eb27316394e3b65ee2c.tar.bz2 |
gh-96611: Fix error message for invalid UTF-8 in mid-multiline string (GH-96623)
(cherry picked from commit 05692c67c51b78a5a5a7bb61d646519025e38015)
Co-authored-by: Michael Droettboom <mdboom@gmail.com>
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 8d7b573..d37914d 100644 --- a/Lib/test/test_source_encoding.py +++ b/Lib/test/test_source_encoding.py @@ -148,6 +148,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: |