(einfo, context=5)
return head + ''.join(frames) + ''.join(exception) + '''

The above is a description of an error in a Python program.  Here is
the original traceback:

%s
''' % ''.join(traceback.format_exception(etype, evalue, etb))
Return a plain text document describing a given traceback.
Return a plain text document describing a given traceback.
Return a plain text document describing a given traceback .
def text(einfo, context=5):
    """Return a plain text document describing a given traceback."""
    etype, evalue, etb = einfo
    if isinstance(etype, type):
        etype = etype.__name__
    pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
    date = time.ctime(time.time())
    head = "%s\n%s\n%s\n" % (str(etype), pyver, date) + '''
A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.
'''

    frames = []
    records = inspect.getinnerframes(etb, context)
    for frame, file, lnum, func, lines, index in records:
        file = file and os.path.abspath(file) or '?'
        args, varargs, varkw, locals = inspect.getargvalues(frame)
        call = ''
        if func != '?':
            call = 'in ' + func
            if func != "<module>":
                call += inspect.formatargvalues(args, varargs, varkw, locals,
                    formatvalue=lambda value: '=' + pydoc.text.repr(value))

        highlight = {}
        def reader(lnum=[lnum]):
            highlight[lnum[0]] = 1
            try: return linecache.getline(file, lnum[0])
            finally: lnum[0] += 1
        vars = scanvars(reader, frame, locals)

        rows = [' %s %s' % (file, call)]
        if index is not None:
            i = lnum - index
            for line in lines:
                num = '%5d ' % i
                rows.append(num+line.rstrip())
                i += 1

        done, dump = {}, []
        for name, where, value in vars:
            if name in done: continue
            done[name] = 1
            if value is not __UNDEF__:
                if where == 'global': name = 'global ' + name
                elif where != 'local': name = where + name.split('.')[-1]
                dump.append('%s = %s' % (name, pydoc.text.repr(value)))
            else:
                dump.append(name + ' undefined')

        rows.append('\n'.join(dump))
        frames.append('\n%s\n' % '\n'.join(rows))

    exception = ['%s: %s' % (str(etype), str(evalue))]
    for name in dir(evalue):
        value = pydoc.text.repr(getattr(evalue, name))
        exception.append('\n%s%s = %s' % (" "*4, name, value))

    return head + ''.join(frames) + ''.join(exception) + '''

The above is a description of an error in a Python program.  Here is
the original traceback:

%s
''' % ''.join(traceback.format_exception(etype, evalue, etb))
def text ( einfo , context = 5 ) : etype , evalue , etb = einfo if isinstance ( etype , type ) : etype = etype . __name__ pyver = 'Python ' + sys . version . split ( ) [ 0 ] + ': ' + sys . executable date = time . ctime ( time . time ( ) ) head = "%s\n%s\n%s\n" % ( str ( etype ) , pyver , date ) + '''
A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.
''' frames = [ ] records = inspect . getinnerframes ( etb , context ) for frame , file , lnum , func , lines , index in records : file = file and os . path . abspath ( file ) or '?' args , varargs , varkw , locals = inspect . getargvalues ( frame ) call = '' if func != '?' : call = 'in ' + func if func != "<module>" : call += inspect . formatargvalues ( args , varargs , varkw , locals , formatvalue = lambda value : '=' + pydoc . text . repr ( value ) ) highlight = { } def reader ( lnum = [ lnum ] ) : highlight [ lnum [ 0 ] ] = 1 try : return linecache . getline ( file , lnum [ 0 ] ) finally : lnum [ 0 ] += 1 vars = scanvars ( reader , frame , locals ) rows = [ ' %s %s' % ( file , call ) ] if index is not None : i = lnum - index for line in lines : num = '%5d ' % i rows . append ( num + line . rstrip ( ) ) i += 1 done , dump = { } , [ ] for name , where , value in vars : if name in done : continue done [ name ] = 1 if value is not __UNDEF__ : if where == 'global' : name = 'global ' + name elif where != 'local' : name = where + name . split ( '.' ) [ - 1 ] dump . append ( '%s = %s' % ( name , pydoc . text . repr ( value ) ) ) else : dump . append ( name + ' undefined' ) rows . append ( '\n' . join ( dump ) ) frames . append ( '\n%s\n' % '\n' . join ( rows ) ) exception = [ '%s: %s' % ( str ( etype ) , str ( evalue ) ) ] for name in dir ( evalue ) : value = pydoc . text . repr ( getattr ( evalue , name ) ) exception . append ( '\n%s%s = %s' % ( " " * 4 , name , value ) ) return head + '' . join ( frames ) + '' . join ( exception ) + '''

The above is a description of an error in a Python program.  Here is
the original traceback:

%s
''' % '' . join ( traceback . format_exception ( etype , evalue , etb ) )