From 7031275776f43c76231318c2158a7a2753bc1fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Wed, 7 Dec 2022 07:55:49 +0100 Subject: gh-93018: Fix for the compatibility problems with expat (gh-93900) --- Lib/test/test_minidom.py | 24 ++++++++-------------- .../2022-06-16-13-26-31.gh-issue-93018.wvNx76.rst | 1 + 2 files changed, 10 insertions(+), 15 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2022-06-16-13-26-31.gh-issue-93018.wvNx76.rst diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index ef38c36..2ca3908 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 0000000..a8fb980 --- /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. -- cgit v0.12