diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 0b68bfa6fe0..92fffc45f30 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -656,11 +656,9 @@ def test2(self): # \xc2\x85 is UTF-8 encoded U+0085 (NEXT LINE) xml = b"\r\n" parser = expat.ParserCreate() - try: + err_pattern = r'XML declaration not well-formed: line 1, column \d+' + with self.assertRaisesRegex(expat.ExpatError, err_pattern): parser.Parse(xml, True) - self.fail() - except expat.ExpatError as e: - self.assertEqual(str(e), 'XML declaration not well-formed: line 1, column 14') class ErrorMessageTest(unittest.TestCase): def test_codes(self): diff --git a/Misc/NEWS b/Misc/NEWS index 3b7411cdf71..835304b5f98 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -90,6 +90,12 @@ C API - Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as an iterable of integers. Now only strings and bytes-like objects are accepted. +Tests +----- + +- Issue #27369: In test_pyexpat, avoid testing an error message detail that + changed in Expat 2.2.0. + Tools/Demos -----------