[Python-Dev] NotImplemented comparisons

Facundo Batista facundobatista at gmail.com
Thu Aug 2 20:11:47 CEST 2007


People:

Pablo Hoffman opened this bug: "[1764761] Decimal comparison with None
fails in Windows".

It's not a Decimal problem, see the differente behaviour of this basic
test in Linux and Windows:

Python 2.5.1 (r251:54863, May  2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu
4.1.2-0ubuntu4)] on linux2
>>> class C(object):
...     def __cmp__(self, other):
...         return NotImplemented
...
>>> c = C()
>>> print c < None
False
>>> print NotImplemented < None
False


Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32
>>> class C(object):
    def __cmp__(self, other):
        return NotImplemented

>>> c = C()
>>> print c < None
True
>>> print NotImplemented < None
False


Here's where I stop: don't know where to keep looking... Does somebody
know why is a difference here?

Furthermore, we can check that is a problem regarding __cmp__:

>>> class C(object):
    def __cmp__(self, other):
        return NotImplemented
    def m(self):
	return NotImplemented

>>> c = C()
>>> print c < None
True
>>> print c.m() < None
False


This is not the first time I find an issue through Decimal regarding
NotImplemented, there was this thread:

    http://mail.python.org/pipermail/python-dev/2005-December/059046.html

, but I don't know if that's a separate issue or not.

Thanks for your help!

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


More information about the Python-Dev mailing list