[issue19880] unittest: on failure, TestCase.run() keeps a reference to the exception

STINNER Victor report at bugs.python.org
Tue Dec 3 23:46:41 CET 2013


New submission from STINNER Victor:

Test attached unittest_leak.py script: you will see MyException.ninstance counter increased up to 10, whereas I expect that MyException is destroyed at TestCase.run() exit.

It looks like a tricky reference cycle between:

- frames
- exc_info local variable of _Outcome.testPartExecutor() context manager
- _Outcome.errors list
- _Outclass instance

Attached unittest_workaround.patch patch works around the issue.

----------
files: unittest_leak.py
messages: 205167
nosy: haypo, pitrou
priority: normal
severity: normal
status: open
title: unittest: on failure, TestCase.run() keeps a reference to the exception
versions: Python 3.4
Added file: http://bugs.python.org/file32951/unittest_leak.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19880>
_______________________________________


More information about the Python-bugs-list mailing list