Last active
October 9, 2019 12:34
-
-
Save dz0/ee5d74146c5c6b1818f39e8d8f2d4f37 to your computer and use it in GitHub Desktop.
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
# based on found https://repl.it/repls/EnlightenedWetFacts | |
import reprlib | |
import traceback, sys | |
traceback.repr = reprlib.repr # make traceback use the reprlib repr because it dumps locals, including the ENTIRETY of __builtins__, which can get a little annoying. | |
i = 0 | |
def foo(): | |
a = 42 | |
global i | |
i += 1 | |
bar(i) | |
def bar(x): | |
x / 0 | |
try: | |
foo() | |
except: | |
tb = traceback.TracebackException(*sys.exc_info(), capture_locals=True) | |
print(''.join(tb.format())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment