[lxml-dev] Segmentation fault in lxml.html after pickling
Stefan Behnel
stefan_ml at behnel.de
Thu Jun 19 11:25:58 CEST 2008
Marcel Hellkamp wrote:
> This script crashes with a segmentation fault :/
>
> import cPickle
> [...]
> tree = lxml.html.fromstring(html)
>
> cf = open('test.pcl', 'w')
> cPickle.dump(tree, cf, -1)
> cf.close()
>
> cf = open('test.pcl', 'r')
> pickled_tree = cPickle.load(cf)
> cf.close()
Yes, you can't pickle Elements in lxml.etree. This feature is currently
only available in lxml.objectify, where Elements behave a lot more like
Python objects.
I think it makes a little less sense in lxml.etree where you'd have to
keep some more state about the Element classes used inside the tree. I'm
not sure how valuable this is in lxml.html.
Could you describe your use case a little?
Stefan
More information about the lxml-dev
mailing list