Hirokazu Yamamoto <ocean-c...@m2.ccsnet.ne.jp> added the comment: The error went away when I commented out following line.
Lib/unittest/case.py(133) self.exception = exc_value.with_traceback(None) I found this by brute force.... I noticed that test_tar_pipe_open_read_error_v2.py starts to fail from r75241. It stores exc_value into _AssertRaisesContext#exception. And when the exception was re-raised like this, (_Stream#_read) try: buf = self.cmp.decompress(buf) except IOError: raise ReadError("invalid compressed data") IOError will be set to ReadError's *__cause__* attribute. ReadError's traceback is cleared in unittest, but IOError's traceback is not. It contains reference to frame which contains _AssertRaisesContext object. And ReadError will be set to _AssertRaisesContext's *exception* attribute, cyclic reference is made. It cannot be freed without GC. # gc.get_referents() was really helpful. I'll attach the test script "test_assert_raises.py" to reproduce the error. The result should be like this. E:\python-dev>py3k test_assert_raises.py -------------------------- [('foo 2',), None, RuntimeError('foo 1',)] RuntimeError('foo 1',) [('foo 1',), <traceback object at 0x00BD2738>] <traceback object at 0x00BD2738> -------------------------- . ---------------------------------------------------------------------- Ran 1 test in 0.090s OK =========================== gc: collectable <cell 00BD0B28> gc: collectable <tuple 00BD0B60> gc: collectable <function 00BCFE78> gc: collectable <tuple 00BD0AF0> gc: collectable <function 00BCFED8> gc: collectable <tuple 00BD0BD0> gc: collectable <function 00BCFF38> gc: collectable <tuple 00BD0C08> gc: collectable <function 00BCFF98> gc: collectable <tuple 00BD0C40> gc: collectable <function 00BD4038> gc: collectable <tuple 00BD0C78> gc: collectable <function 00BD4098> gc: collectable <tuple 00BD0CB0> gc: collectable <function 00BD40F8> gc: collectable <function 00BD4158> gc: collectable <type 00C07550> gc: collectable <dict 00B1FAB8> gc: collectable <getset_descriptor 00BD2678> gc: collectable <getset_descriptor 00BD26B8> gc: collectable <tuple 00AC53F8> gc: collectable <frame 00C08858> gc: collectable <method 00AC43F8> gc: collectable <frame 00C09628> gc: collectable <tuple 00BD0038> gc: collectable <frame 00C097D0> gc: collectable <frame 00C09978> gc: collectable <frame 00C0C1B8> gc: collectable <frame 00C0CEF0> gc: collectable <tuple 00BD0E38> gc: collectable <frame 00C0D098> gc: collectable <method 00AC43B8> gc: collectable <frame 00C0D810> gc: collectable <_AssertRaisesContext 00BD0F18> gc: collectable <frame 00C0DF18> gc: collectable <tuple 00BD0EA8> gc: collectable <RuntimeError 00B9FC50> gc: collectable <traceback 00BD2738> gc: collectable <tuple 00BD0F50> gc: collectable <ValueError 00B9FC98> gc: collectable <dict 00B22818> gc: collectable <method 00AC4338> gc: collectable <tuple 00BD0B98> gc: collectable <tuple_iterator 00BD0E70> gc: collectable <map 00BD0EE0> gc: collectable <list 00B21938> =========================== gc: 46 uncollectable objects at shutdown: [45415 refs] ---------- Added file: http://bugs.python.org/file18876/test_assert_raises.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9815> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com