[Python-bugs-list] [ python-Bugs-451309 ] don't store traceback objects

noreply@sourceforge.net noreply@sourceforge.net
Wed, 15 Aug 2001 14:46:01 -0700


Bugs item #451309, was opened at 2001-08-15 13:36
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=451309&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 6
Submitted By: Jeremy Hylton (jhylton)
Assigned to: Steve Purcell (purcell)
Summary: don't store traceback objects

Initial Comment:
A TestResult object stores the exceptions raised when
tests fail.  The only use of these stored tracebacks,
it seems, is to print a stack trace when the test run's
report is generated.

The traceback objects, however, keep pointers to a bunch
of objects that might otherwise be garbage collected. 
I ran into this on Windows, where the traceback was
keeping a file object alive.  Because the file object
was not collected, my tearDown() method could not
remove the file.

This patch changes unittest to generate the formatted
traceback immediately, so that it does not keep
tracebacks around any longer than needed.


----------------------------------------------------------------------

>Comment By: Steve Purcell (purcell)
Date: 2001-08-15 14:46

Message:
Logged In: YES 
user_id=21477

Hi Jeremy,

This behaviour is actually known and intentional; the 
dangers are documented as a caveat in the PyUnit docs. The 
intention was that a test runner (GUI or otherwise) could 
potentially make the traceback available for inspection 
when a test fails, to aid in debugging.

In your particular case, relying on GC to close the file 
might have caused problems with following code even if 
PyUnit didn't store the traceback.

Overall I'd prefer to keep storing the tracebacks, 
especially since they only get stored when tests fail. It 
would be worth me adding a note about GC interaction to 
the docs, though.


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=451309&group_id=5470