Skip to content

Commit 2f1b1ff

Browse files
committed
Merged revisions 83864 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83864 | florent.xicluna | 2010-08-09 01:08:41 +0200 (lun., 09 août 2010) | 2 lines Fix xml.etree.ElementInclude to include the tail of the current node. Issue python#6231 ........
1 parent 0fad1c2 commit 2f1b1ff

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎Lib/test/test_xml_etree.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,14 @@ def processinginstruction():
12591259

12601260
XINCLUDE["count.txt"] = "324387"
12611261

1262+
XINCLUDE["C2b.xml"] = """\
1263+
<?xml version='1.0'?>
1264+
<document xmlns:xi="http://www.w3.org/2001/XInclude">
1265+
<p>This document has been <em>accessed</em>
1266+
<xi:include href="count.txt" parse="text"/> times.</p>
1267+
</document>
1268+
"""
1269+
12621270
XINCLUDE["C3.xml"] = """\
12631271
<?xml version='1.0'?>
12641272
<document xmlns:xi="http://www.w3.org/2001/XInclude">
@@ -1334,6 +1342,16 @@ def xinclude():
13341342
324387 times.</p>
13351343
</document>
13361344
1345+
Textual inclusion after sibling element (based on modified XInclude C.2)
1346+
1347+
>>> document = xinclude_loader("C2b.xml")
1348+
>>> ElementInclude.include(document, xinclude_loader)
1349+
>>> print(serialize(document)) # C2b
1350+
<document>
1351+
<p>This document has been <em>accessed</em>
1352+
324387 times.</p>
1353+
</document>
1354+
13371355
Textual inclusion of XML example (XInclude C.3)
13381356
13391357
>>> document = xinclude_loader("C3.xml")

‎Lib/xml/etree/ElementInclude.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def include(elem, loader=None):
125125
)
126126
if i:
127127
node = elem[i-1]
128-
node.tail = (node.tail or "") + text
128+
node.tail = (node.tail or "") + text + (e.tail or "")
129129
else:
130130
elem.text = (elem.text or "") + text + (e.tail or "")
131131
del elem[i]

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Core and Builtins
2929
Library
3030
-------
3131

32+
- Issue #6231: Fix xml.etree.ElementInclude to include the tail of the
33+
current node.
34+
3235
- Issue #6869: Fix a refcount problem in the _ctypes extension.
3336

3437
- Issue5504 - ctypes should now work with systems where mmap can't be

0 commit comments

Comments
 (0)