
On Wed, 19 Oct 2011 13:10:22 -0400 "Itamar Turner-Trauring" <itamar@itamarst.org> wrote:
For example, I could post the following patch for t.p.failure, but would you accept it?
@@ -464,6 +468,14 @@ class Failure: # added 2003-06-23. See comment above in __init__ c['tb'] = None
+ try: + # Clear other references held by exception objects + c['value'].__cause__ = None + c['value'].__context__ = None + c['value'].__traceback__ = None + except AttributeError: + pass + if self.stack is not None: # XXX: This is a band-aid. I can't figure out where these # (failure.stack is None) instances are coming from.
That sort of patch would probably be fine, though I'd much rather that be inside an if statement that checked the Python version rather than inside a try/except. Faster, and much clearer what's going on.
The try/except is necessary because Failures sometimes wrap something else than an exception, and where setting an arbitrary attribute is not allowed. Regards Antoine.