New submission from Leonardo Soto <leosoto@...>:
Basically, dict-derived classes shouldn't raise TypeError when being
compared with non-dictionary instances:
>>> class dictderived(dict): pass
>>> dictderived() == ''
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: dict.__cmp__(x,y) requires y to be 'dict', not a 'str'
The compatible behavior in this case is to check if __cmp__ has been
overridden by the dict subclass. If not, the "default comparison" (by
class name) should be done.
[A more complete description of my findings is on
http://blog.leosoto.com/2008/04/python-comparison-weirdness.html, but I
think that creating a TestCase reflecting what's written there is better
than pasting it here]
title: PyDictionaryDerived.__cmp__ is not fully CPython-compatible
Jython tracker <report@...>