mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
bpo-46054: Fix parsing error when parsing non-utf8 characters in source files (GH-30068)
This commit is contained in:
parent
59435eea08
commit
4325a766f5
3 changed files with 19 additions and 8 deletions
|
@ -2387,6 +2387,18 @@ class SyntaxErrorTests(unittest.TestCase):
|
|||
finally:
|
||||
unlink(TESTFN)
|
||||
|
||||
def test_non_utf8(self):
|
||||
# Check non utf-8 characters
|
||||
try:
|
||||
with open(TESTFN, 'bw') as testfile:
|
||||
testfile.write(b'\x7fELF\x02\x01\x01\x00\x00\x00')
|
||||
rc, out, err = script_helper.assert_python_failure('-Wd', '-X', 'utf8', TESTFN)
|
||||
err = err.decode('utf-8').splitlines()
|
||||
|
||||
self.assertEqual(err[-1], "SyntaxError: invalid non-printable character U+007F")
|
||||
finally:
|
||||
unlink(TESTFN)
|
||||
|
||||
def test_attributes_new_constructor(self):
|
||||
args = ("bad.py", 1, 2, "abcdefg", 1, 100)
|
||||
the_exception = SyntaxError("bad bad", args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue