We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8ad7e3b commit e378638Copy full SHA for e378638
html5lib/treebuilders/etree.py
@@ -207,8 +207,12 @@ def serializeElement(element, indent=0):
207
rv.append("<!DOCTYPE %s>" % (element.text,))
208
elif element.tag == "DOCUMENT_ROOT":
209
rv.append("#document")
210
- assert element.text is None
211
- assert element.tail is None
+ if element.text is not None:
+ raise TypeError("Document node cannot have text")
212
+ if element.tail is not None:
213
+ raise TypeError("Document node cannot have tail")
214
+ if hasattr(element, "attrib") and len(element.attrib):
215
+ raise TypeError("Document node cannot have attributes")
216
elif element.tag == ElementTreeCommentType:
217
rv.append("|%s<!-- %s -->" % (' ' * indent, element.text))
218
else:
0 commit comments