From: Florent Xicluna Date: Sun, 8 Aug 2010 23:08:41 +0000 (+0000) Subject: Fix xml.etree.ElementInclude to include the tail of the current node. Issue #6231 X-Git-Tag: v3.2a2~407 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ba8a98600eddc5e2a87a9148e634ada1a1056495;p=thirdparty%2FPython%2Fcpython.git Fix xml.etree.ElementInclude to include the tail of the current node. Issue #6231 --- diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 4c9f2e070b37..39997cc5ee93 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1277,6 +1277,14 @@ XINCLUDE["C2.xml"] = """\ XINCLUDE["count.txt"] = "324387" +XINCLUDE["C2b.xml"] = """\ + + +

This document has been accessed + times.

+
+""" + XINCLUDE["C3.xml"] = """\ @@ -1352,6 +1360,16 @@ def xinclude(): 324387 times.

+ Textual inclusion after sibling element (based on modified XInclude C.2) + + >>> document = xinclude_loader("C2b.xml") + >>> ElementInclude.include(document, xinclude_loader) + >>> print(serialize(document)) # C2b + +

This document has been accessed + 324387 times.

+
+ Textual inclusion of XML example (XInclude C.3) >>> document = xinclude_loader("C3.xml") diff --git a/Lib/xml/etree/ElementInclude.py b/Lib/xml/etree/ElementInclude.py index dde0a41531c0..84fd7548b28a 100644 --- a/Lib/xml/etree/ElementInclude.py +++ b/Lib/xml/etree/ElementInclude.py @@ -125,7 +125,7 @@ def include(elem, loader=None): ) if i: node = elem[i-1] - node.tail = (node.tail or "") + text + node.tail = (node.tail or "") + text + (e.tail or "") else: elem.text = (elem.text or "") + text + (e.tail or "") del elem[i] diff --git a/Misc/NEWS b/Misc/NEWS index c5fe3d81dee6..46ddfef855c2 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -63,6 +63,9 @@ Extensions Library ------- +- Issue #6231: Fix xml.etree.ElementInclude to include the tail of the + current node. + - Issue #8047: Fix the xml.etree serializer to return bytes by default. Use ``encoding="unicode"`` to generate a Unicode string.