[Python-checkins] gh-93018: Fix for the compatibility problems with expat (gh-93900)

corona10 webhook-mailer at python.org
Wed Dec 7 01:55:59 EST 2022


https://github.com/python/cpython/commit/7031275776f43c76231318c2158a7a2753bc1fba
commit: 7031275776f43c76231318c2158a7a2753bc1fba
branch: main
author: Matěj Cepl <mcepl at cepl.eu>
committer: corona10 <donghee.na92 at gmail.com>
date: 2022-12-07T15:55:49+09:00
summary:

gh-93018: Fix for the compatibility problems with expat (gh-93900)

files:
A Misc/NEWS.d/next/Tests/2022-06-16-13-26-31.gh-issue-93018.wvNx76.rst
M Lib/test/test_minidom.py

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 @@ 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'<fran\xe7ais></fran\xe7ais>')
-            self.assertRaises(ExpatError, parseString,
-                    b'<franais>Comment \xe7a va ? Tr\xe8s bien ?</franais>')
-        else:
-            self.assertRaises(UnicodeDecodeError, parseString,
-                b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
+        with self.assertRaises((UnicodeDecodeError, ExpatError)):
+            parseString(
+                b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>'
+            )
 
         doc.unlink()
 
@@ -1631,13 +1627,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('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')
+        with self.assertRaises((ValueError, ExpatError)):
+            parseString(
+                '<element xmlns:abc="http:abc.com/de f g/hi/j k">' +
+                '<abc:foo /></element>'
+            )
 
     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.



More information about the Python-checkins mailing list