Message3173

Author leosoto
Recipients leosoto
Date 2008-05-02.16:07:30
SpamBayes Score 0.000999637
Marked as misclassified No
Message-id <1209744451.01.0.952466459416.issue1031@psf.upfronthosting.co.za>
In-reply-to
Content
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]
History
Date User Action Args
2008-05-02 16:07:31leosotosetspambayes_score: 0.000999637 -> 0.000999637
recipients: + leosoto
2008-05-02 16:07:31leosotosetspambayes_score: 0.000999637 -> 0.000999637
messageid: <1209744451.01.0.952466459416.issue1031@psf.upfronthosting.co.za>
2008-05-02 16:07:30leosotolinkissue1031 messages
2008-05-02 16:07:30leosotocreate