'Display the exception that just occurred.
We remove the first stack item because it is our own code.
The output is written by self.write(), below.'

def showtraceback(self):

    (sys.last_type, sys.last_value, last_tb) = ei = sys.exc_info()
    sys.last_traceback = last_tb
    try:
        lines = traceback.format_exception(ei[0], ei[1], last_tb.tb_next)
        if (sys.excepthook is sys.__excepthook__):
            self.write(''.join(lines))
        else:
            sys.excepthook(ei[0], ei[1], last_tb)
    finally:
        last_tb = ei = None
