[New-bugs-announce] [issue1513] object.c do_compare comparison ordering error

Joseph Armbruster report at bugs.python.org
Wed Nov 28 17:25:09 CET 2007


New submission from Joseph Armbruster:

URL: http://svn.python.org/projects/python/branches/py3k
Rev: 59215

Session illustrating issue:

>>> a = None
[40667 refs]
>>> cmp(a,None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: NoneType() < NoneType()
[40715 refs]

Resolution: It appears the equality comparison in do_compare should take
place first, otherwise a TypeError thwarts the desired comparison.

rt.bat Results (I can only test core, since I do not have the third
party libs here):

Failed tests before change:
  test_ctypes test_mailbox

Failed tests after change:
  test_copy test_ctypes test_mailbox

test_copy is failing because of this block:

    def test_deepcopy_reflexive_dict(self):
        x = {}
        x['foo'] = x
        y = copy.deepcopy(x)
        self.assertRaises(TypeError, cmp, y, x)
        self.assert_(y is not x)
        self.assert_(y['foo'] is y)
        self.assertEqual(len(y), 1)

A RuntimeError now occurs instead.

        self.assertRaises(RuntimeError, cmp, y, x)

Additional Patch Note:

If this is a valid patch, please add a comment prior to the code change
that indicates the EQ test is first for a good reason.

----------
components: Interpreter Core
files: noneEquality.patch
messages: 57914
nosy: JosephArmbruster, loewis, tiran
severity: normal
status: open
title: object.c do_compare comparison ordering error
type: behavior
versions: Python 3.0
Added file: http://bugs.python.org/file8818/noneEquality.patch

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1513>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: noneEquality.patch
Type: text/x-diff
Size: 844 bytes
Desc: not available
Url : http://mail.python.org/pipermail/new-bugs-announce/attachments/20071128/4214730e/attachment.patch 


More information about the New-bugs-announce mailing list