New submission from Hirokazu Yamamoto <ocean-c...@m2.ccsnet.ne.jp>: Hello. Sorry if this is noise. I expected
__del__ out of function __del__ out of function __del__ out of function on following code, but actually I got out of function out of function out of function __del__ __del__ __del__ Is this expected behavoir? (I believed `a' would be freed after returned from f(), so I was suprised) If I remove the comment of gc.collect(), the code works as expected. /////////////////////////////// import gc class A: def __del__(self): print("__del__") def f(): a = A() def g(): a g() def main(): for _ in range(3): f() # gc.collect() print("out of function") if __name__ == '__main__': main() ---------- components: Interpreter Core messages: 79664 nosy: ocean-city severity: normal status: open title: Object lifetime and inner recursive function versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4921> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com