[Python-bugs-list] [ python-Bugs-594959 ] Reference count error (new class object)

noreply@sourceforge.net noreply@sourceforge.net
Wed, 14 Aug 2002 02:18:14 -0700


Bugs item #594959, was opened at 2002-08-14 08:32
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=594959&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2.1
>Status: Closed
>Resolution: Out of Date
Priority: 5
Submitted By: Henric Ericsson (henric_ericsson)
>Assigned to: Michael Hudson (mwh)
Summary: Reference count error (new class object)

Initial Comment:
When sorting a list of new class objects
that has a __cmp__() method the reference counters
are incremented.

Example code:
--------------------------
import sys

class Test2(object):
    def __init__(self, nr):
        self.nr = nr

    def __cmp__(self, other):
        return self.nr - other.nr

l = map(Test2, range(10))
print map(sys.getrefcount, l)
l.sort()
print map(sys.getrefcount, l)
--------------------------
Output:
--------------------------
[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
[2, 3, 3, 3, 3, 3, 3, 3, 3, 3]
--------------------------

I'm attaching another test prgram.


----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2002-08-14 09:18

Message:
Logged In: YES 
user_id=6656

This seems to have been fixed, both on the trunk and the
22-maint branch.

No idea which checkin fixed it, I'd have to admit...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=594959&group_id=5470