[Python-Dev] Garbage collecting closures

Paul Prescod paul@prescod.net
Fri, 11 Apr 2003 16:59:29 -0700

Does this bug look familiar to anyone?

import gc

def bar(a):
     def foo():
         return None
         x = a

class C:pass
a = C()

for i in range(20):
     print len(gc.get_referrers(a))
     x = bar(a)

On my Python, it just counts up. "a" gets more and more referrers and 
they are "cell" objects. If it is unknown, I'll submit a bug report 
unless someone fixes it before I get to it. ;)

  Paul Prescod