Commit 6d6fb3aa authored by Ezio Melotti's avatar Ezio Melotti

#15970: xml.etree.ElementTree now serializes correctly the empty HTML elements "meta" and "param".

parent ba372a59
......@@ -1822,6 +1822,26 @@ def check_issue6565():
"""
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>'
"""
# --------------------------------------------------------------------
......
......@@ -945,7 +945,7 @@ def _serialize_xml(write, elem, encoding, qnames, namespaces):
write(_escape_cdata(elem.tail, encoding))
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)
......
......@@ -103,6 +103,9 @@ Core and Builtins
Library
-------
- Issue #15970: xml.etree.ElementTree now serializes correctly the empty HTML
elements 'meta' and 'param'.
- Issue #15676: Now "mmap" check for empty files before doing the
offset check. Patch by Steven Willis.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment