[lxml-dev] Hashing objectify.StringElement

Hi all, It's my first question on the list and I tried to find the answer but couldn't so if my question has indeed been answered before just point me there please :-) I'm updating some API which used to use etree.Element objects to objectify because I need to pickle this items and from what I've read so far, this seems like the way to go. At some point in the code elements are used as dictionary keys and this used to work before, but now I get a TypeError telling me that 'lxml.objectify.StringElement' is unhashable. However, 'lxml.objectify.ObjectifiedElement' class is hashable. Also, I found that the __hash__ function seems to be implemented, but for some reason calling hash() or trying to use StringElement as a dictionary key will give this error. Is this a bug? A feature? Can I get around this somehow? Thanks in advance and kind regards, PS: I'm using version 2.2.6-1 on Debian squeeze. -- Saúl Ibarra Corretgé AG Projects

On 09/21/2010 05:57 PM, Saúl Ibarra Corretgé wrote:
Hi all,
It's my first question on the list and I tried to find the answer but couldn't so if my question has indeed been answered before just point me there please :-)
I'm updating some API which used to use etree.Element objects to objectify because I need to pickle this items and from what I've read so far, this seems like the way to go.
At some point in the code elements are used as dictionary keys and this used to work before, but now I get a TypeError telling me that 'lxml.objectify.StringElement' is unhashable. However, 'lxml.objectify.ObjectifiedElement' class is hashable.
Also, I found that the __hash__ function seems to be implemented, but for some reason calling hash() or trying to use StringElement as a dictionary key will give this error.
Is this a bug? A feature? Can I get around this somehow?
Thanks in advance and kind regards,
PS: I'm using version 2.2.6-1 on Debian squeeze.
Fun, I just found the answer right after sending the email :-S So it's already fixed in trunk :-) http://comments.gmane.org/gmane.comp.python.lxml.devel/5339 -- Saúl Ibarra Corretgé AG Projects
participants (1)
-
Saúl Ibarra Corretgé