From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 21 Feb 2022 16:16:23 +0000 (-0800) Subject: bpo-46811: Make test suite support Expat >=2.4.5 (GH-31453) (GH-31469) X-Git-Tag: archive/raspbian/3.9.2-1+rpi1+deb11u2^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=15886292c67b1b70aa150c630989592704a88a1d;p=python3.9.git bpo-46811: Make test suite support Expat >=2.4.5 (GH-31453) (GH-31469) Curly brackets were never allowed in namespace URIs according to RFC 3986, and so-called namespace-validating XML parsers have the right to reject them a invalid URIs. libexpat >=2.4.5 has become strcter in that regard due to related security issues; with ET.XML instantiating a namespace-aware parser under the hood, this test has no future in CPython. References: - https://datatracker.ietf.org/doc/html/rfc3968 - https://www.w3.org/TR/xml-names/ Also, test_minidom.py: Support Expat >=2.4.5 (cherry picked from commit 2cae93832f46b245847bdc252456ddf7742ef45e) Co-authored-by: Sebastian Pipping Co-authored-by: Sebastian Pipping Gbp-Pq: Name 0028-bpo-46811-Make-test-suite-support-Expat-2.4.5-GH-314.patch --- diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 1663b1f..5f52ed1 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -6,10 +6,12 @@ import io from test import support import unittest +import pyexpat import xml.dom.minidom from xml.dom.minidom import parse, Node, Document, parseString from xml.dom.minidom import getDOMImplementation +from xml.parsers.expat import ExpatError tstfile = support.findfile("test.xml", subdir="xmltestdata") @@ -1147,8 +1149,10 @@ class MinidomTest(unittest.TestCase): # Verify that character decoding errors raise exceptions instead # of crashing - self.assertRaises(UnicodeDecodeError, parseString, - b'Comment \xe7a va ? Tr\xe8s bien ?') + self.assertRaises(ExpatError, parseString, + b'') + self.assertRaises(ExpatError, parseString, + b'Comment \xe7a va ? Tr\xe8s bien ?') doc.unlink() @@ -1609,7 +1613,9 @@ class MinidomTest(unittest.TestCase): self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE) def testExceptionOnSpacesInXMLNSValue(self): - with self.assertRaisesRegex(ValueError, 'Unsupported syntax'): + context = self.assertRaisesRegex(ExpatError, 'syntax error') + + with context: parseString('') def testDocRemoveChild(self): diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 5632b8b..2ac643f 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -2159,12 +2159,6 @@ class BugsTest(unittest.TestCase): b"\n" b'tãg') - def test_issue3151(self): - e = ET.XML('') - self.assertEqual(e.tag, '{${stuff}}localname') - t = ET.ElementTree(e) - self.assertEqual(ET.tostring(e), b'') - def test_issue6565(self): elem = ET.XML("") self.assertEqual(summarize_list(elem), ['tag'])