Last active
August 29, 2015 14:01
-
-
Save vindolin/b451626ebd331cff23fd to your computer and use it in GitHub Desktop.
This file contains 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
# from http://stackoverflow.com/a/14776693/999193 | |
import sys | |
def myexcepthook(type, value, tb): | |
import traceback | |
from pygments import highlight | |
from pygments.lexers import get_lexer_by_name | |
from pygments.formatters import TerminalFormatter | |
tbtext = ''.join(traceback.format_exception(type, value, tb)) | |
lexer = get_lexer_by_name("pytb", stripall=True) | |
formatter = TerminalFormatter() | |
sys.stderr.write(highlight(tbtext, lexer, formatter)) | |
sys.excepthook = myexcepthook |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment