◐ Shell
clean mode source ↗

Message 57914 - Python tracker

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.