After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 345961 - provide a __hash__ method for xmlNode objects
provide a __hash__ method for xmlNode objects
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.x
Other All
: Normal enhancement
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-06-26 14:21 UTC by Andreas Pakulat
Modified: 2006-06-26 19:44 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
adds a __hash__ function to xmlCore (2.61 KB, patch)
2006-06-26 14:23 UTC, Andreas Pakulat
none Details | Review

Description Andreas Pakulat 2006-06-26 14:21:42 UTC
Hi,

here's another feature that I need when I want to use libxml2's python bindings. It adds the __hash__ function to xmlCore (and thus to all xmlNode objects), so that xmlNode's can be used as key for python dictionaries.

The patch uses the xmlNodePtr and lets the python function PyLong_FromVoidPtr create a long for the pointer. This way __hash__ always returns the same value when the underlying C-Node is the same, which is needed as libxml2 creates new python objects on each call to children, for example.

Patch will be attached and also includes a small testcase. I would try to also test what happens when an invalid node is given to the function, but I didn't know how to create an invalid xmlNode from within python.

Andreas
Comment 1 Andreas Pakulat 2006-06-26 14:23:18 UTC
Created attachment 68031 [details] [review]
adds a __hash__ function to xmlCore

As I explained in the report, this adds the __hash__ function to xmlCore which uses the xmlNodePtr for the returned long value.
Comment 2 William M. Brack 2006-06-26 18:29:25 UTC
I have combined this request with bug 345779, included the testing within the other test program, and committed to CVS.

Bill
Comment 3 Andreas Pakulat 2006-06-26 18:50:34 UTC
Thanks for that. Will this be available in libxml 2.7 oder only in 3.x? I'd just like to know what I have to state in the requirements for my application...
Comment 4 William M. Brack 2006-06-26 19:44:26 UTC
Unless someone discovers any problem caused by this change, it will appear in the next release (presumably 2.6.27), so currently your requirement would be libxml2 >= 2.6.27