From: Matěj Cepl Date: Wed, 7 Dec 2022 06:55:49 +0000 (+0100) Subject: gh-93018: Fix for the compatibility problems with expat (gh-93900) X-Git-Tag: v3.12.0a4~278 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7031275776f43c76231318c2158a7a2753bc1fba;p=thirdparty%2FPython%2Fcpython.git gh-93018: Fix for the compatibility problems with expat (gh-93900) --- diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index ef38c362103f..2ca3908bd1ca 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -1163,14 +1163,10 @@ class MinidomTest(unittest.TestCase): # Verify that character decoding errors raise exceptions instead # of crashing - if pyexpat.version_info >= (2, 4, 5): - self.assertRaises(ExpatError, parseString, - b'') - self.assertRaises(ExpatError, parseString, - b'Comment \xe7a va ? Tr\xe8s bien ?') - else: - self.assertRaises(UnicodeDecodeError, parseString, - b'Comment \xe7a va ? Tr\xe8s bien ?') + with self.assertRaises((UnicodeDecodeError, ExpatError)): + parseString( + b'Comment \xe7a va ? Tr\xe8s bien ?' + ) doc.unlink() @@ -1631,13 +1627,11 @@ class MinidomTest(unittest.TestCase): self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE) def testExceptionOnSpacesInXMLNSValue(self): - if pyexpat.version_info >= (2, 4, 5): - context = self.assertRaisesRegex(ExpatError, 'syntax error') - else: - context = self.assertRaisesRegex(ValueError, 'Unsupported syntax') - - with context: - parseString('') + with self.assertRaises((ValueError, ExpatError)): + parseString( + '' + + '' + ) def testDocRemoveChild(self): doc = parse(tstfile) diff --git a/Misc/NEWS.d/next/Tests/2022-06-16-13-26-31.gh-issue-93018.wvNx76.rst b/Misc/NEWS.d/next/Tests/2022-06-16-13-26-31.gh-issue-93018.wvNx76.rst new file mode 100644 index 000000000000..a8fb98048e40 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-06-16-13-26-31.gh-issue-93018.wvNx76.rst @@ -0,0 +1 @@ +Make two tests forgiving towards host system libexpat with backported security fixes applied.