problem calling ElementTree._ElementInterface.find with PyObject_CallObject

sndive at gmail.com sndive at gmail.com
Wed Nov 14 20:15:23 EST 2007


I have a weid problem. If i do this:
import elementtree.ElementTree as ET
...
    tree = ET.parse("whatever")
    root = tree.getroot()
    r = root.find('last')
    print r
    return root
where last is not an immediate child of root node i get back None.
However if i comment the r = root.find('last')
    print r
part out and PyObject_CallObject on root from c++ space
i get

Traceback (most recent call last):
  File "/var/tmp/build/x86-ezx/lib/python2.4/site-packages/elementtree/
ElementTree.py", line 329, in find
    return ElementPath.find(self, path)
  File "/var/tmp/build/x86-ezx/lib/python2.4/site-packages/elementtree/
ElementPath.py", line 188, in find
    return _compile(path).find(element)
  File "/var/tmp/build/x86-ezx/lib/python2.4/site-packages/elementtree/
ElementPath.py", line 178, in _compile
    p = Path(path)
  File "/var/tmp/build/x86-ezx/lib/python2.4/site-packages/elementtree/
ElementPath.py", line 70, in __init__
    tokens = xpath_tokenizer(path)
AttributeError: _ElementInterface instance has no attribute 'last'

(the call to PyObject_CallObject works fine if root.find on the
requested attribute was performed first
from python space!!!)

this is with ElementTree 1.2.6 if that matters here at all



More information about the Python-list mailing list