[Python-Dev] porting pycxx and pysvn to python 3.0 hit a problem

Barry Scott barry at barrys-emacs.org
Tue Oct 7 23:52:32 CEST 2008

On Oct 5, 2008, at 19:47, Martin v. Löwis wrote:

>> Why does "key in wc_status_kind_wc" work when I use an object  
>> returned
>> by keys() by not when I use pysvn.wc_status_kind.unversioned?
> This is too little detail to come up with an explanation. Do your
> objects support __eq__.
> Regards,
> Martin

I wrote a smaller version of the code that fails and had a session with

My object implements tp_compare but lookdict() uses richcompare.
If richcompare is not implemented do_richcompare() falls back to
comparing PyObject * pointers - which is cause of the KeyError
as the objects cmp() eq but have different PyObect * values.

This is a change from V2 python where to be a key implementing
tp_hash and tp_compare is sufficient.

In V3 is it your intention that to be a key you must implement
tp_hash and tp_richcompare? If not I'll raise a bug against
3.0 on this issue.


More information about the Python-Dev mailing list