summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-04 23:40:52 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-07-04 23:40:52 (GMT)
commit6597aa16b6044d8b5e31e176fed1865471499f08 (patch)
tree26e7b7405fa3ec9e394b80dd368cc367d8662b95
parent260fbe80c5bd3611ae9e896a3c4714527667aece (diff)
parent54ad7e39dfe429795cc908a9a03a94c485c87cc2 (diff)
downloadcpython-6597aa16b6044d8b5e31e176fed1865471499f08.zip
cpython-6597aa16b6044d8b5e31e176fed1865471499f08.tar.gz
cpython-6597aa16b6044d8b5e31e176fed1865471499f08.tar.bz2
Issue #18347: ElementTree's html serializer now preserves the case of closing tags.
-rw-r--r--Lib/test/test_xml_etree.py7
-rw-r--r--Lib/xml/etree/ElementTree.py6
-rw-r--r--Misc/NEWS3
3 files changed, 13 insertions, 3 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 6c5bf02..e2ffc19 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -742,6 +742,13 @@ class ElementTreeTest(unittest.TestCase):
'<html><link><script>1 < 2</script></html>\n')
self.assertEqual(serialize(e, method="text"), '1 < 2\n')
+ def test_issue18347(self):
+ e = ET.XML('<html><CamelCase>text</CamelCase></html>')
+ self.assertEqual(serialize(e),
+ '<html><CamelCase>text</CamelCase></html>')
+ self.assertEqual(serialize(e, method="html"),
+ '<html><CamelCase>text</CamelCase></html>')
+
def test_entity(self):
# Test entity handling.
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index edf2581..56c91cc 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -992,15 +992,15 @@ def _serialize_html(write, elem, qnames, namespaces, **kwargs):
# 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(text)
else:
write(_escape_cdata(text))
for e in elem:
_serialize_html(write, e, qnames, None)
- if tag not in HTML_EMPTY:
+ if ltag not in HTML_EMPTY:
write("</" + tag + ">")
if elem.tail:
write(_escape_cdata(elem.tail))
diff --git a/Misc/NEWS b/Misc/NEWS
index fc50537..f3a099d 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -135,6 +135,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 #18343: faulthandler.register() now keeps the previous signal handler