def dump_exception(typ, val, tb):
 tbtext = ''.join(traceback.format_exception(typ, val, tb))
 (sys.last_type, sys.last_value, sys.last_traceback) = (typ, val, tb)
 try:
  pickled_exc = pickle.dumps((typ, val, tbtext), protocol=PICKLE_PROTOCOL)
 except pickle.PicklingError as ex:
  newval = NestedException(('pickling error %s\nexception type: %r\nexception object: %s' % (ex, typ, val)))
  pickled_exc = pickle.dumps((NestedException, newval, tbtext), protocol=PICKLE_PROTOCOL)
 return pickled_exc

def dump_exception ( typ , val , tb ) : tbtext = '' . join ( traceback . format_exception ( typ , val , tb ) ) ( sys . last_type , sys . last_value , sys . last_traceback ) = ( typ , val , tb ) try : pickled_exc = pickle . dumps ( ( typ , val , tbtext ) , protocol = PICKLE_PROTOCOL ) except pickle . PicklingError as ex : newval = NestedException ( ( 'pickling error %s\nexception type: %r\nexception object: %s' % ( ex , typ , val ) ) ) pickled_exc = pickle . dumps ( ( NestedException , newval , tbtext ) , protocol = PICKLE_PROTOCOL ) return pickled_exc
dumps the given exception using pickle .