def find_pickleable_exception(exc, loads=pickle.loads, dumps=pickle.dumps):
 exc_args = getattr(exc, u'args', [])
 for supercls in itermro(exc.__class__, unwanted_base_classes):
  try:
   superexc = supercls(*exc_args)
   loads(dumps(superexc))
  except Exception:
   pass
  else:
   return superexc

def find_pickleable_exception ( exc , loads = pickle . loads , dumps = pickle . dumps ) : exc_args = getattr ( exc , u'args' , [ ] ) for supercls in itermro ( exc . __class__ , unwanted_base_classes ) : try : superexc = supercls ( * exc_args ) loads ( dumps ( superexc ) ) except Exception : pass else : return superexc
find first pickleable exception base class .