lxml.etree._ElementTree.find() fails on objectify.parse result
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Medium
|
scoder |
Bug Description
If a tree was created by objectify.parse, I can't use find() on it, I need to use getroot().find():
>>> from lxml import objectify
>>> from StringIO import StringIO
>>> f = StringIO(
>>> tree = objectify.parse(f)
>>> tree.find.
'find(self, path, namespaces=None)'
>>> tree.find('/root')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "lxml.etree.pyx", line 1944, in lxml.etree.
TypeError: find() takes exactly one argument (2 given)
>>> tree.getroot(
'find(self, path)'
>>> tree.getroot(
<Element root at 0x7f1655843a50>
>>> tree.getroot(
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: find() takes exactly one argument (2 given)
This testcase is also attached.
Here tree.find('/root') actually translates to tree.getroot(
Python : (2, 6, 7, 'final', 0)
lxml.etree : (2, 3, 0, 0)
libxml used : (2, 7, 8)
libxml compiled : (2, 7, 8)
libxslt used : (1, 1, 26)
libxslt compiled : (1, 1, 26)
Hmm, right - I guess ObjectifiedElem ent.find* () would better use ObjectPath expressions than ElementPath.