diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index 97620258d82f6b..9c3d955cf41942 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1149,14 +1149,10 @@ def testEncodings(self):
# 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()
@@ -1617,13 +1613,11 @@ def testEmptyXMLNSValue(self):
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 00000000000000..a8fb98048e4023
--- /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.