From: Raymond Hettinger Date: Mon, 24 Jun 2002 13:25:41 +0000 (+0000) Subject: Fix SF Bug 572567: Memory leak in object comparison X-Git-Tag: v2.2.2b1~302 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d605adfe2ddc92aaf373c1d07416ac9c9f926e45;p=thirdparty%2FPython%2Fcpython.git Fix SF Bug 572567: Memory leak in object comparison --- diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index a526ad4769ff..2b38ecc4fa8b 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1105,6 +1105,18 @@ def slots(): gc.collect() vereq(Counted.counter, 0) + # Test lookup leaks [SF bug 572567] + import sys,gc + class G(object): + def __cmp__(self, other): + return 0 + g = G() + orig_objects = len(gc.get_objects()) + for i in xrange(10): + g==g + new_objects = len(gc.get_objects()) + vereq(orig_objects, new_objects) + def dynamics(): if verbose: print "Testing class attribute propagation..." class D(object): diff --git a/Misc/ACKS b/Misc/ACKS index c9d8cc93692a..a35b72387114 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -219,6 +219,7 @@ John Interrante Ben Jackson Paul Jackson David Jacobs +Kevin Jacobs Jack Jansen Bill Janssen Drew Jenkins diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 09e4aa7e945c..1a99a1eb825d 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3177,6 +3177,7 @@ half_compare(PyObject *self, PyObject *other) res = PyObject_Call(func, args, NULL); Py_DECREF(args); } + Py_DECREF(func); if (res != Py_NotImplemented) { if (res == NULL) return -2;