From: SourceForge.net <no...@so...> - 2006-05-30 10:41:04
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3756087 By: fabioz You can put that anywhere, as long as you call it before getting into that exception. And it should give you the globals and the locals in the stack-trace. It is not the same as stopping at that exact time, but it gives you the complete info on the stack. Actually, I passed one thing wrong, you should change the sys.excepthook and not the sys.__excepthook__. Below is a complete example showing how you'd get the locals in the stack-trace. Cheers, Fabio ----------------- Example ------------ import sys def m1(a = 10): raise RuntimeError('here') if __name__ == '__main__': def myHook(type, value, traceback): initial_ctx = traceback.tb_next while initial_ctx.tb_next is not None: initial_ctx = initial_ctx.tb_next print 'locals on exception:', initial_ctx.tb_frame.f_locals #now, call the original. sys.__excepthook__(type, value, traceback) sys.excepthook = myHook m1() ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |