]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18347: ElementTree's html serializer now preserves the case of closing tags.
authorChristian Heimes <christian@cheimes.de>
Thu, 4 Jul 2013 23:41:30 +0000 (01:41 +0200)
committerChristian Heimes <christian@cheimes.de>
Thu, 4 Jul 2013 23:41:30 +0000 (01:41 +0200)
Lib/test/test_xml_etree.py
Lib/xml/etree/ElementTree.py
Misc/NEWS

index 4e161ca2f3acd9dd33a0eed08579b7e9d1afa348..4f06d20c0458961bccc2bd6e130e4036e3e4636a 100644 (file)
@@ -1769,6 +1769,16 @@ def bug_200709_iter_comment():
 
     """
 
+def bug_18347():
+    """
+
+    >>> e = ET.XML('<html><CamelCase>text</CamelCase></html>')
+    >>> serialize(e)
+    '<html><CamelCase>text</CamelCase></html>'
+    >>> serialize(e, method="html")
+    '<html><CamelCase>text</CamelCase></html>'
+    """
+
 # --------------------------------------------------------------------
 # reported on bugs.python.org
 
index bb468cde698c1d3df421fdb0e47f35acef7cf10d..9f3e75d4a6f0d39c10c59911b438ccbcc05d5202 100644 (file)
@@ -988,15 +988,15 @@ def _serialize_html(write, elem, encoding, qnames, namespaces):
                     # FIXME: handle boolean attributes
                     write(" %s=\"%s\"" % (qnames[k], v))
             write(">")
-            tag = tag.lower()
+            ltag = tag.lower()
             if text:
-                if tag == "script" or tag == "style":
+                if ltag == "script" or ltag == "style":
                     write(_encode(text, encoding))
                 else:
                     write(_escape_cdata(text, encoding))
             for e in elem:
                 _serialize_html(write, e, encoding, qnames, None)
-            if tag not in HTML_EMPTY:
+            if ltag not in HTML_EMPTY:
                 write("</" + tag + ">")
     if elem.tail:
         write(_escape_cdata(elem.tail, encoding))
index fec41b73424d91f0fe219f6fc0d6849b3957a598..8114b696af8c16612bc32a055cbbb2e670624112 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #18347: ElementTree's html serializer now preserves the case of
+  closing tags.
+
 - Issue #17261: Ensure multiprocessing's proxies use proper address.
 
 - Issue #17097: Make multiprocessing ignore EINTR.