mirror of
https://github.com/python/cpython.git
synced 2025-09-11 19:27:07 +00:00
gh-96611: Fix error message for invalid UTF-8 in mid-multiline string (GH-96623)
(cherry picked from commit 05692c67c5
)
Co-authored-by: Michael Droettboom <mdboom@gmail.com>
This commit is contained in:
parent
a389fdb095
commit
bb0dab5c48
3 changed files with 16 additions and 0 deletions
|
@ -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:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue