Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upetree serializer fails when serializing lxml.html element containing a comment #340
Comments
|
Okay, it looks like it might work to pass
Outputs:
|
|
Closing as the ElementTree API doesn't seem to expose a way to detect comments (other than checking the type directly). The documentation could perhaps be improved to list |


Calling
html5lib.serialize()fails when passingtree='etree'and an element containing comments created bylxml.html.This should work because
lxml.html's documentation says about itself:Passing
tree='lxml'doesn't work as a work-around in general because of this issue: #338To reproduce:
Here is the exception:
I'm guessing this issue is caused by the type-checking being done in this line:
Instead of exact type-checking which is more fragile, I wonder if some form of duck-typing can be used or using something in the ElementTree API itself.