Skip to content

Instantly share code, notes, and snippets.

@dz0
Last active October 9, 2019 12:34
Show Gist options
  • Save dz0/ee5d74146c5c6b1818f39e8d8f2d4f37 to your computer and use it in GitHub Desktop.
Save dz0/ee5d74146c5c6b1818f39e8d8f2d4f37 to your computer and use it in GitHub Desktop.
# 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