def ex(e):
 e_message = u''
 if ((not e) or (not e.args)):
  return e_message
 for arg in e.args:
  if (arg is not None):
   if isinstance(arg, (str, unicode)):
    fixed_arg = fixStupidEncodings(arg, True)
   else:
    try:
     fixed_arg = (u'error ' + fixStupidEncodings(str(arg), True))
    except:
     fixed_arg = None
   if fixed_arg:
    if (not e_message):
     e_message = fixed_arg
    else:
     e_message = ((e_message + ' : ') + fixed_arg)
 return e_message

def ex ( e ) : e_message = u'' if ( ( not e ) or ( not e . args ) ) : return e_message for arg in e . args : if ( arg is not None ) : if isinstance ( arg , ( str , unicode ) ) : fixed_arg = fixStupidEncodings ( arg , True ) else : try : fixed_arg = ( u'error ' + fixStupidEncodings ( str ( arg ) , True ) ) except : fixed_arg = None if fixed_arg : if ( not e_message ) : e_message = fixed_arg else : e_message = ( ( e_message + ' : ' ) + fixed_arg ) return e_message
returns a unicode string from the exception text if it exists .