summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_source_encoding.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-06 23:36:03 (GMT)
committerGitHub <noreply@github.com>2022-09-06 23:36:03 (GMT)
commitb6af9337163e03cc853aa15905658748abef0901 (patch)
tree29068fe420334661335e26045a054abbc59a64b7 /Lib/test/test_source_encoding.py
parent6ac0f8f0d795bba678be56bd4b0bb9ae3fbedb15 (diff)
downloadcpython-b6af9337163e03cc853aa15905658748abef0901.zip
cpython-b6af9337163e03cc853aa15905658748abef0901.tar.gz
cpython-b6af9337163e03cc853aa15905658748abef0901.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.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_source_encoding.py b/Lib/test/test_source_encoding.py
index a0cb605..219c25c 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: