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

This commit is contained in:
Matěj Cepl 2022-12-07 07:55:49 +01:00 committed by GitHub
parent 889b0b9bf9
commit 7031275776
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 15 deletions

View file

@ -1163,14 +1163,10 @@ class MinidomTest(unittest.TestCase):
# Verify that character decoding errors raise exceptions instead # Verify that character decoding errors raise exceptions instead
# of crashing # of crashing
if pyexpat.version_info >= (2, 4, 5): with self.assertRaises((UnicodeDecodeError, ExpatError)):
self.assertRaises(ExpatError, parseString, parseString(
b'<fran\xe7ais></fran\xe7ais>') b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</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>')
doc.unlink() doc.unlink()
@ -1631,13 +1627,11 @@ class MinidomTest(unittest.TestCase):
self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE) self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)
def testExceptionOnSpacesInXMLNSValue(self): def testExceptionOnSpacesInXMLNSValue(self):
if pyexpat.version_info >= (2, 4, 5): with self.assertRaises((ValueError, ExpatError)):
context = self.assertRaisesRegex(ExpatError, 'syntax error') parseString(
else: '<element xmlns:abc="http:abc.com/de f g/hi/j k">' +
context = self.assertRaisesRegex(ValueError, 'Unsupported syntax') '<abc:foo /></element>'
)
with context:
parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')
def testDocRemoveChild(self): def testDocRemoveChild(self):
doc = parse(tstfile) doc = parse(tstfile)

View file

@ -0,0 +1 @@
Make two tests forgiving towards host system libexpat with backported security fixes applied.