def bytes_to_text(s, encoding):
 if isinstance(s, bytes):
  return six.text_type(s, encoding, u'replace')
 else:
  return s

def bytes_to_text ( s , encoding ) : if isinstance ( s , bytes ) : return six . text_type ( s , encoding , u'replace' ) else : return s
converts basestring objects to unicode .