[issue6737] PEP 372 odict.__eq__ behaves incorrectly
Christopher Egner
report at bugs.python.org
Thu Aug 20 00:29:15 CEST 2009
New submission from Christopher Egner <cegner at yahoo-inc.com>:
The current definition for odict.__eq__ is
def __eq__(self, other):
if isinstance(other, OrderedDict):
return all(p==q for p, q in _zip_longest(self.items(),
other.items()))
return dict.__eq__(self, other)
The current behavior of NotImplemented is:
>>> if( NotImplemented ):
... print 'foo'
foo
>>> dict.__eq__( {}, None )
NotImplemented
>>> if ( dict.__eq__( {}, None ) ):
... print 'oops'
oops
The surprising behavior is:
>>> if ( OrderedDict() != None ):
... print 'okie'
... else:
... print 'gah!'
gah!
As best I understand it, normally other (in this case None) would be
given the chance to evaluate other.__eq__( OrderedDict() ), but this
doesn't seem to be happening.
----------
components: None
messages: 91752
nosy: cegner
severity: normal
status: open
title: PEP 372 odict.__eq__ behaves incorrectly
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6737>
_______________________________________
More information about the Python-bugs-list
mailing list