for_element doesn't work for fragments
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Confirmed
|
Medium
|
Unassigned |
Bug Description
When using the for_element property of a label on a tree created from a html fragment that does not contain a body tag, an IndexError is raised:
Traceback (most recent call last):
File "B:\Workspace\
open(
File "B:\Workspace\
print label.for_element
File "C:\Program Files (x86)\Python27\
return self.body.
File "C:\Program Files (x86)\Python27\
return self.xpath(
IndexError: list index out of range
This can be fixed by searching for elements from the fragment root, not the (potentially missing) body tag
Python : sys.version_
lxml.etree : (3, 2, 3, 0)
libxml used : (2, 9, 0)
libxml compiled : (2, 9, 0)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)
Agreed that that would be better. Patches welcome.