From ab5dae35ca5d64cf08c2a48105af4f92dd53b27d Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Mon, 24 Jun 2002 13:08:16 +0000 Subject: Fix SF bug 572567: Memory leak in object comparison. --- Lib/test/test_descr.py | 12 ++++++++++++ Misc/ACKS | 1 + Objects/typeobject.c | 1 + 3 files changed, 14 insertions(+) diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index dca8ea1..ea67c4e 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1163,6 +1163,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 fb64941..ed9b80c 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -233,6 +233,7 @@ John Interrante Ben Jackson Paul Jackson David Jacobs +Kevin Jacobs Geert Jansen Jack Jansen Bill Janssen diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 47613f5..2beb3b3 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3286,6 +3286,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; -- cgit v0.12