Skip to content

Commit b8f8e3d

Browse files
committed
Fix ElementTree treewalker under cElementTree on Python 2.6.
This is effectively the treewalker equivalent of 3e50aad: Don't rely on the ElementTree Comment factory being the tag attribute on Comments. This is needed for xml.etree.cElementTree under 2.6 (and likely hence custom installs of cElementTree 1.2), where the tag property is equal to xml.etree.ElementTree.Comment (i.e., the pure Python version).
1 parent 627969f commit b8f8e3d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

html5lib/treewalkers/etree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
def getETreeBuilder(ElementTreeImplementation):
1717
ElementTree = ElementTreeImplementation
18+
ElementTreeCommentType = ElementTree.Comment("asd").tag
1819

1920
class TreeWalker(_base.NonRecursiveTreeWalker):
2021
"""Given the particular ElementTree representation, this implementation,
@@ -48,7 +49,7 @@ def getNodeDetails(self, node):
4849
return (_base.DOCTYPE, node.text,
4950
node.get("publicId"), node.get("systemId"))
5051

51-
elif node.tag == ElementTree.Comment:
52+
elif node.tag == ElementTreeCommentType:
5253
return _base.COMMENT, node.text
5354

5455
else:

0 commit comments

Comments
 (0)