[Python-checkins] bpo-46054: Correct non-utf8 character tests in test_exceptions (GH-30074)

pablogsal webhook-mailer at python.org
Sun Dec 12 11:53:05 EST 2021


https://github.com/python/cpython/commit/c6d1c52c166968fb722ae26d44aa2c1c030dc613
commit: c6d1c52c166968fb722ae26d44aa2c1c030dc613
branch: main
author: Pablo Galindo Salgado <Pablogsal at gmail.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2021-12-12T16:53:00Z
summary:

bpo-46054: Correct non-utf8 character tests in test_exceptions (GH-30074)

files:
M Lib/test/test_exceptions.py

diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 102102669db16..ffcb5e1ff5ad1 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -2391,11 +2391,11 @@ 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')
+                testfile.write(b"\x89")
             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")
+            self.assertIn("SyntaxError: Non-UTF-8 code starting with '\\x89' in file", err[-1])
         finally:
             unlink(TESTFN)
 



More information about the Python-checkins mailing list