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

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