def format_exception(msg, *args, **kwargs):
 tb = traceback.extract_tb(sys.exc_info()[2], limit=1)
 if (len(tb) > 0):
  (filename, lineno, func, text) = tb[0]
 else:
  filename = lineno = func = text = u'<unknown>'
 return msg.format(filename=filename, lineno=lineno, func=func, text=text, *args, **kwargs)

def format_exception ( msg , * args , ** kwargs ) : tb = traceback . extract_tb ( sys . exc_info ( ) [ 2 ] , limit = 1 ) if ( len ( tb ) > 0 ) : ( filename , lineno , func , text ) = tb [ 0 ] else : filename = lineno = func = text = u'<unknown>' return msg . format ( filename = filename , lineno = lineno , func = func , text = text , * args , ** kwargs )
format a stack trace and the exception information .