element find removes for subsequent calls
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
New
|
Undecided
|
Unassigned |
Bug Description
% python3 lxmlReport.py
Python : sys.version_
lxml.etree : (4, 9, 2, 0)
libxml used : (2, 9, 14)
libxml compiled : (2, 9, 14)
libxslt used : (1, 1, 35)
libxslt compiled : (1, 1, 35)
I have a function
def getSolid(self, sname) :
#return self.solids.
ret = self.solids.
if ret is not None:
print(ret)
return ret
I call it once and it outputs
getSolid : <Element solids at 0x10589eb00> 163 VTBox2
b'<box xmlns:xsi="http://
<Element box at 0x1058b2e40>
solidDict {'VTBox2': <Element box at 0x1058b2e40>}
I call it from a different place with same info and get
getSolid : <Element solids at 0x10589eb00> 162 VTBox2
None
Solid : VTBox2 Not Found
I note the length of the Element on the second call is one less i.e. 162
It looks like the find call is removing the element.
Thanks for the report, but there shouldn't be anything in .find() that would change the document.
Is this repeatable? I.e., if you call it multiple times, does an element disappear each time?
Could you remove the "printElement()" call, and also any further code on the caller side, to make sure it's lxml that does the tree modification and not something on your side? A short, complete reproducer would help.