[Python-bugs-list] [ python-Bugs-681122 ] Built-in function dir() causes refcount leak in baseclasses

SourceForge.net noreply@sourceforge.net
Wed, 05 Feb 2003 11:41:58 -0800


Bugs item #681122, was opened at 2003-02-05 13:17
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=681122&group_id=5470

Category: Python Library
Group: Python 2.2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Troels Walsted Hansen (troels)
>Assigned to: Tim Peters (tim_one)
Summary: Built-in function dir() causes refcount leak in baseclasses

Initial Comment:
The bug appears to be present in Python 2.2.2 and 2.3a, 
but not in 2.2 or 2.2.1.

import sys

class Top:
    pass

class Bottom(Top):
    pass

print 'Refcount before:', sys.getrefcount(Top)
b=Bottom()
for i in range(1000):
    dir(b)
print 'Refcount after:', sys.getrefcount(Top)

$ ~/py221/bin/python refcount.py
Refcount before: 3
Refcount after: 3

$ ~/py222/bin/python refcount.py
Refcount before: 3
Refcount after: 1003

$ ~/py23a1/bin/python refcount.py
Refcount before: 3
Refcount after: 1003


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

>Comment By: Tim Peters (tim_one)
Date: 2003-02-05 14:41

Message:
Logged In: YES 
user_id=31435

Good detective work!  It helps.  Fixed, in

Objects/object.c; new revision: 2.197

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

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