Menu ▾ ▴

#1 Re-raise exceptions correctly, when running strict

open
nobody
None
5
2009-07-23
2009-07-23
No

First, thanks for tinpy it's nice and simple...

I've noticed that when exceptions are re-raised in DictEnhanceAccessor.__getitem__ (line 178) the previous tracestack of the exception is discarded.
Instead of:
if self.strict: raise Exception, e
You should use:
if self.strict: raise

This will, according to python documentation [1], re-raise the previous exception. This means that the previous stacktrace will be preserved, which makes it a lot easier to debug. This feature is increasingly important if you put logic into the __getitem__ method of object you pass as dict to tinpy.build as vars :)

//Regards Jonas Finnemann Jensen.

[1] http://docs.python.org/reference/simple_stmts.html#raise

Discussion


Log in to post a comment.