Created
January 3, 2012 04:10
-
-
Save evanlong/1553435 to your computer and use it in GitHub Desktop.
dump stack info along with locals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def foo(n): | |
a = "Hello" | |
b = "bob" | |
c = 1 / n | |
return a + " " + b | |
def bar(): | |
a = foo(1) | |
b = foo(0) | |
print a | |
print b | |
def baz(): | |
bar() | |
#basic global handler to dump exception with locals information | |
try: | |
baz() | |
except BaseException,e: | |
tbo = sys.exc_info()[2] | |
while tbo != None: | |
print tbo.tb_frame.f_code | |
print " ", tbo.tb_frame.f_locals | |
tbo = tbo.tb_next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment