summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-09-19 05:19:12 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-09-19 05:19:12 (GMT)
commitc90111f9ab617a1dbdde8952a4b81e6eecc36e7c (patch)
tree30cfe26e68b81949199bb5a2166ad3641b3579a0
parentab02db23b1032c7b1fcf7063ae736b25e4466624 (diff)
downloadcpython-c90111f9ab617a1dbdde8952a4b81e6eecc36e7c.zip
cpython-c90111f9ab617a1dbdde8952a4b81e6eecc36e7c.tar.gz
cpython-c90111f9ab617a1dbdde8952a4b81e6eecc36e7c.tar.bz2
#15970: xml.etree.ElementTree now serializes correctly the empty HTML elements "meta" and "param".
-rw-r--r--Lib/test/test_xml_etree.py20
-rw-r--r--Lib/xml/etree/ElementTree.py2
-rw-r--r--Misc/NEWS3
3 files changed, 24 insertions, 1 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index b7a996c..3092f3b 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1851,6 +1851,26 @@ def check_issue10777():
>>> ET.register_namespace('test10777', 'http://myuri/')
"""
+def check_html_empty_elems_serialization(self):
+ # issue 15970
+ # from http://www.w3.org/TR/html401/index/elements.html
+ """
+
+ >>> empty_elems = ['AREA', 'BASE', 'BASEFONT', 'BR', 'COL', 'FRAME', 'HR',
+ ... 'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM']
+ >>> elems = ''.join('<%s />' % elem for elem in empty_elems)
+ >>> serialize(ET.XML('<html>%s</html>' % elems), method='html')
+ '<html><AREA><BASE><BASEFONT><BR><COL><FRAME><HR><IMG><INPUT><ISINDEX><LINK><META><PARAM></html>'
+ >>> serialize(ET.XML('<html>%s</html>' % elems.lower()), method='html')
+ '<html><area><base><basefont><br><col><frame><hr><img><input><isindex><link><meta><param></html>'
+ >>> elems = ''.join('<%s></%s>' % (elem, elem) for elem in empty_elems)
+ >>> serialize(ET.XML('<html>%s</html>' % elems), method='html')
+ '<html><AREA><BASE><BASEFONT><BR><COL><FRAME><HR><IMG><INPUT><ISINDEX><LINK><META><PARAM></html>'
+ >>> serialize(ET.XML('<html>%s</html>' % elems.lower()), method='html')
+ '<html><area><base><basefont><br><col><frame><hr><img><input><isindex><link><meta><param></html>'
+
+ """
+
# --------------------------------------------------------------------
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index f94c48c..9742f32 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -983,7 +983,7 @@ def _serialize_xml(write, elem, qnames, namespaces):
write(_escape_cdata(elem.tail))
HTML_EMPTY = ("area", "base", "basefont", "br", "col", "frame", "hr",
- "img", "input", "isindex", "link", "meta" "param")
+ "img", "input", "isindex", "link", "meta", "param")
try:
HTML_EMPTY = set(HTML_EMPTY)
diff --git a/Misc/NEWS b/Misc/NEWS
index 29e2c19..5113ec0 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -120,6 +120,9 @@ Core and Builtins
Library
-------
+- Issue #15970: xml.etree.ElementTree now serializes correctly the empty HTML
+ elements 'meta' and 'param'.
+
- Issue #15842: the SocketIO.{readable,writable,seekable} methods now
raise ValueError when the file-like object is closed. Patch by Alessandro
Moura.