[New-bugs-announce] [issue7104] test_descr uses __cmp__ which will never be called
Daniel Stutzbach
report at bugs.python.org
Sun Oct 11 18:32:13 CEST 2009
New submission from Daniel Stutzbach <daniel at stutzbachenterprises.com>:
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)
----------
components: Tests
messages: 93862
nosy: stutzbach
severity: normal
status: open
title: test_descr uses __cmp__ which will never be called
versions: Python 3.0, Python 3.1, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7104>
_______________________________________
More information about the New-bugs-announce
mailing list