GC question

Kerim Borchaev warkid at storm.ru
Thu Nov 8 13:24:26 EST 2001


Hello ,

While trying to use gc I've encountered a problem, demonstrated by
this script:
######################################
from __future__ import nested_scopes

import gc
gc.enable()
gc.set_debug(gc.DEBUG_LEAK)


def fun():
    class C:
        def m(self):
            g = C()
fun()
del fun

gc.collect()
assert not gc.garbage, str(gc.garbage)
######################################

It's output:
######################################
gc: collectable <cell 007E8F8C>
gc: collectable <dictionary 007E0ACC>
gc: collectable <function 007EACA4>
gc: collectable <tuple 007E8FB4>
gc: collectable <class 007E0B3C>
Traceback (most recent call last):
  File "t.py", line 16, in ?
    assert not gc.garbage, str(gc.garbage)
AssertionError: [<cell at 007E8F8C: class object at 007E0B3C>, {'__doc__': None, 'm': <function m at
 007EACA4>, '__module__': '__main__'}, <function m at 007EACA4>, (<cell at 007E8F8C: class object at
 007E0B3C>,), <class __main__.C at 007E0B3C>]
######################################

can someone, please, explain what does it mean and why it happens?

 My python is:
ActivePython 2.1.1, build 212 (ActiveState)
Python 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on win32

Best regards,
 Kerim                          mailto:warkid at storm.ru






More information about the Python-list mailing list