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

75b047
From a5b78c6f1c802f6023bd4d7a248dc83be1eef6a3 Mon Sep 17 00:00:00 2001
75b047
From: Sebastian Pipping <sebastian@pipping.org>
75b047
Date: Mon, 21 Feb 2022 15:48:32 +0100
75b047
Subject: [PATCH] 00378: Support expat 2.4.5
75b047
75b047
Curly brackets were never allowed in namespace URIs
75b047
according to RFC 3986, and so-called namespace-validating
75b047
XML parsers have the right to reject them a invalid URIs.
75b047
75b047
libexpat >=2.4.5 has become strcter in that regard due to
75b047
related security issues; with ET.XML instantiating a
75b047
namespace-aware parser under the hood, this test has no
75b047
future in CPython.
75b047
75b047
References:
75b047
- https://datatracker.ietf.org/doc/html/rfc3968
75b047
- https://www.w3.org/TR/xml-names/
75b047
75b047
Also, test_minidom.py: Support Expat >=2.4.5
75b047
75b047
Upstream: https://bugs.python.org/issue46811
75b047
75b047
Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
75b047
---
75b047
 Lib/test/test_minidom.py                             | 12 +++++++++---
75b047
 Lib/test/test_xml_etree.py                           |  6 ------
75b047
 .../Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst |  1 +
75b047
 3 files changed, 10 insertions(+), 9 deletions(-)
75b047
 create mode 100644 Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst
75b047
75b047
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
75b047
index d55e25e..e947382 100644
75b047
--- a/Lib/test/test_minidom.py
75b047
+++ b/Lib/test/test_minidom.py
75b047
@@ -5,10 +5,12 @@ import pickle
75b047
 from test import support
75b047
 import unittest
75b047
 
75b047
+import pyexpat
75b047
 import xml.dom.minidom
75b047
 
75b047
 from xml.dom.minidom import parse, Node, Document, parseString
75b047
 from xml.dom.minidom import getDOMImplementation
75b047
+from xml.parsers.expat import ExpatError
75b047
 
75b047
 
75b047
 tstfile = support.findfile("test.xml", subdir="xmltestdata")
75b047
@@ -1156,8 +1158,10 @@ class MinidomTest(unittest.TestCase):
75b047
 
75b047
         # Verify that character decoding errors raise exceptions instead
75b047
         # of crashing
75b047
-        self.assertRaises(UnicodeDecodeError, parseString,
75b047
-                b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
75b047
+        self.assertRaises(ExpatError, parseString,
75b047
+                b'<fran\xe7ais></fran\xe7ais>')
75b047
+        self.assertRaises(ExpatError, parseString,
75b047
+                b'<franais>Comment \xe7a va ? Tr\xe8s bien ?</franais>')
75b047
 
75b047
         doc.unlink()
75b047
 
75b047
@@ -1602,7 +1606,9 @@ class MinidomTest(unittest.TestCase):
75b047
         self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)
75b047
 
75b047
     def testExceptionOnSpacesInXMLNSValue(self):
75b047
-        with self.assertRaisesRegex(ValueError, 'Unsupported syntax'):
75b047
+        context = self.assertRaisesRegex(ExpatError, 'syntax error')
75b047
+
75b047
+        with context:
75b047
             parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')
75b047
 
75b047
     def testDocRemoveChild(self):
75b047
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
75b047
index b01709e..acaa519 100644
75b047
--- a/Lib/test/test_xml_etree.py
75b047
+++ b/Lib/test/test_xml_etree.py
75b047
@@ -1668,12 +1668,6 @@ class BugsTest(unittest.TestCase):
75b047
                 b"\n"
75b047
                 b'<body>tãg</body>')
75b047
 
75b047
-    def test_issue3151(self):
75b047
-        e = ET.XML('<prefix:localname xmlns:prefix="${stuff}"/>')
75b047
-        self.assertEqual(e.tag, '{${stuff}}localname')
75b047
-        t = ET.ElementTree(e)
75b047
-        self.assertEqual(ET.tostring(e), b'<ns0:localname xmlns:ns0="${stuff}" />')
75b047
-
75b047
     def test_issue6565(self):
75b047
         elem = ET.XML("<body><tag/></body>")
75b047
         self.assertEqual(summarize_list(elem), ['tag'])
75b047
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
75b047
new file mode 100644
75b047
index 0000000..6969bd1
75b047
--- /dev/null
75b047
+++ b/Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst
75b047
@@ -0,0 +1 @@
75b047
+Make test suite support Expat >=2.4.5
75b047
-- 
75b047
2.35.1
75b047