[Python-checkins] r83864 - in python/branches/py3k: Lib/test/test_xml_etree.py Lib/xml/etree/ElementInclude.py Misc/NEWS

florent.xicluna python-checkins at python.org
Mon Aug 9 01:08:41 CEST 2010


Author: florent.xicluna
Date: Mon Aug  9 01:08:41 2010
New Revision: 83864

Log:
Fix xml.etree.ElementInclude to include the tail of the current node.  Issue #6231


Modified:
   python/branches/py3k/Lib/test/test_xml_etree.py
   python/branches/py3k/Lib/xml/etree/ElementInclude.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/test/test_xml_etree.py
==============================================================================
--- python/branches/py3k/Lib/test/test_xml_etree.py	(original)
+++ python/branches/py3k/Lib/test/test_xml_etree.py	Mon Aug  9 01:08:41 2010
@@ -1277,6 +1277,14 @@
 
 XINCLUDE["count.txt"] = "324387"
 
+XINCLUDE["C2b.xml"] = """\
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+  <p>This document has been <em>accessed</em>
+  <xi:include href="count.txt" parse="text"/> times.</p>
+</document>
+"""
+
 XINCLUDE["C3.xml"] = """\
 <?xml version='1.0'?>
 <document xmlns:xi="http://www.w3.org/2001/XInclude">
@@ -1352,6 +1360,16 @@
       324387 times.</p>
     </document>
 
+    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
+    <document>
+      <p>This document has been <em>accessed</em>
+      324387 times.</p>
+    </document>
+
     Textual inclusion of XML example (XInclude C.3)
 
     >>> document = xinclude_loader("C3.xml")

Modified: python/branches/py3k/Lib/xml/etree/ElementInclude.py
==============================================================================
--- python/branches/py3k/Lib/xml/etree/ElementInclude.py	(original)
+++ python/branches/py3k/Lib/xml/etree/ElementInclude.py	Mon Aug  9 01:08:41 2010
@@ -125,7 +125,7 @@
                         )
                 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]

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Mon Aug  9 01:08:41 2010
@@ -63,6 +63,9 @@
 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.
 


More information about the Python-checkins mailing list