Blame SOURCES/00378-support-expat-2-4-5.patch

bb807a
From 3950e203a4c625b7bc53e67e96d5d5239758f4fa Mon Sep 17 00:00:00 2001
bb807a
From: "Miss Islington (bot)"
bb807a
 <31488909+miss-islington@users.noreply.github.com>
bb807a
Date: Mon, 21 Feb 2022 08:16:23 -0800
bb807a
Subject: [PATCH] bpo-46811: Make test suite support Expat >=2.4.5 (GH-31453)
bb807a
 (GH-31469)
bb807a
bb807a
Curly brackets were never allowed in namespace URIs
bb807a
according to RFC 3986, and so-called namespace-validating
bb807a
XML parsers have the right to reject them a invalid URIs.
bb807a
bb807a
libexpat >=2.4.5 has become strcter in that regard due to
bb807a
related security issues; with ET.XML instantiating a
bb807a
namespace-aware parser under the hood, this test has no
bb807a
future in CPython.
bb807a
bb807a
References:
bb807a
- https://datatracker.ietf.org/doc/html/rfc3968
bb807a
- https://www.w3.org/TR/xml-names/
bb807a
bb807a
Also, test_minidom.py: Support Expat >=2.4.5
bb807a
(cherry picked from commit 2cae93832f46b245847bdc252456ddf7742ef45e)
bb807a
bb807a
Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
bb807a
bb807a
Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
bb807a
---
bb807a
 Lib/test/test_minidom.py                             | 12 +++++++++---
bb807a
 Lib/test/test_xml_etree.py                           |  6 ------
bb807a
 .../Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst |  1 +
bb807a
 3 files changed, 10 insertions(+), 9 deletions(-)
bb807a
 create mode 100644 Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst
bb807a
bb807a
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
bb807a
index 1663b1f..5f52ed1 100644
bb807a
--- a/Lib/test/test_minidom.py
bb807a
+++ b/Lib/test/test_minidom.py
bb807a
@@ -6,10 +6,12 @@ import io
bb807a
 from test import support
bb807a
 import unittest
bb807a
 
bb807a
+import pyexpat
bb807a
 import xml.dom.minidom
bb807a
 
bb807a
 from xml.dom.minidom import parse, Node, Document, parseString
bb807a
 from xml.dom.minidom import getDOMImplementation
bb807a
+from xml.parsers.expat import ExpatError
bb807a
 
bb807a
 
bb807a
 tstfile = support.findfile("test.xml", subdir="xmltestdata")
bb807a
@@ -1147,8 +1149,10 @@ class MinidomTest(unittest.TestCase):
bb807a
 
bb807a
         # Verify that character decoding errors raise exceptions instead
bb807a
         # of crashing
bb807a
-        self.assertRaises(UnicodeDecodeError, parseString,
bb807a
-                b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
bb807a
+        self.assertRaises(ExpatError, parseString,
bb807a
+                b'<fran\xe7ais></fran\xe7ais>')
bb807a
+        self.assertRaises(ExpatError, parseString,
bb807a
+                b'<franais>Comment \xe7a va ? Tr\xe8s bien ?</franais>')
bb807a
 
bb807a
         doc.unlink()
bb807a
 
bb807a
@@ -1609,7 +1613,9 @@ class MinidomTest(unittest.TestCase):
bb807a
         self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)
bb807a
 
bb807a
     def testExceptionOnSpacesInXMLNSValue(self):
bb807a
-        with self.assertRaisesRegex(ValueError, 'Unsupported syntax'):
bb807a
+        context = self.assertRaisesRegex(ExpatError, 'syntax error')
bb807a
+
bb807a
+        with context:
bb807a
             parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')
bb807a
 
bb807a
     def testDocRemoveChild(self):
bb807a
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
bb807a
index 23c4cd5..142ce2c 100644
bb807a
--- a/Lib/test/test_xml_etree.py
bb807a
+++ b/Lib/test/test_xml_etree.py
bb807a
@@ -2159,12 +2159,6 @@ class BugsTest(unittest.TestCase):
bb807a
                 b"\n"
bb807a
                 b'<body>tãg</body>')
bb807a
 
bb807a
-    def test_issue3151(self):
bb807a
-        e = ET.XML('<prefix:localname xmlns:prefix="${stuff}"/>')
bb807a
-        self.assertEqual(e.tag, '{${stuff}}localname')
bb807a
-        t = ET.ElementTree(e)
bb807a
-        self.assertEqual(ET.tostring(e), b'<ns0:localname xmlns:ns0="${stuff}" />')
bb807a
-
bb807a
     def test_issue6565(self):
bb807a
         elem = ET.XML("<body><tag/></body>")
bb807a
         self.assertEqual(summarize_list(elem), ['tag'])
bb807a
diff --git a/Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst b/Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst
bb807a
new file mode 100644
bb807a
index 0000000..6969bd1
bb807a
--- /dev/null
bb807a
+++ b/Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst
bb807a
@@ -0,0 +1 @@
bb807a
+Make test suite support Expat >=2.4.5
bb807a
-- 
bb807a
2.37.3
bb807a