[lxml-dev] segfault when using etree.CustomElementClassLookup

Martijn Faassen faassen at startifact.com
Tue Jun 3 20:30:07 CEST 2008


Hi there,

I just ran into a segfault with lxml (2.0.6). The problem is as follows:

from lxml import etree

class Lookup(etree.CustomElementClassLookup):
     def __init__(self):
         pass

     def lookup(self, node_type, document, namespace, name):
         return Foo

class Foo(etree.ElementBase):
     def custom(self):
         return "test"

lookup = Lookup()
parser = etree.XMLParser()
parser.setElementClassLookup(lookup)

root = etree.XML('<foo/>', parser) # crash!

If I leave out the custom __init__ in Lookup, things won't crash.

Regards,

Martijn



More information about the lxml-dev mailing list