Issue 7104: test_descr uses cmp which will never be called (original) (raw)

The following is from Lib/test/test_descr.py. It's trying to test if looking up a special method on an object leaks references. It tests it by using cmp. The test will always pass because Python 3 is trying to look up eq, not cmp. Hence, cmp should be changed to eq.

    # Test lookup leaks [SF bug 572567]
    import sys,gc
    if hasattr(gc, 'get_objects'):
        class G(object):
            def __cmp__(self, other):
                return 0
        g = G()
        orig_objects = len(gc.get_objects())
        for i in range(10):
            g==g
        new_objects = len(gc.get_objects())
        self.assertEqual(orig_objects, new_objects)