(s, encoding='utf-8', errors='strict')
Coerce *s* to six.text_type.

    For Python 2:
      - `unicode` -> `unicode`
      - `str` -> `unicode`

    For Python 3:
      - `str` -> `str`
      - `bytes` -> decoded to `str`
Coerce *s* to six.text_type.
Coerce * s * to six . text_type .
def ensure_text(s, encoding='utf-8', errors='strict'):
    """Coerce *s* to six.text_type.

    For Python 2:
      - `unicode` -> `unicode`
      - `str` -> `unicode`

    For Python 3:
      - `str` -> `str`
      - `bytes` -> decoded to `str`
    """
    if isinstance(s, binary_type):
        return s.decode(encoding, errors)
    elif isinstance(s, text_type):
        return s
    else:
        raise TypeError("not expecting type '%s'" % type(s))
def ensure_text ( s , encoding = 'utf-8' , errors = 'strict' ) : if isinstance ( s , binary_type ) : return s . decode ( encoding , errors ) elif isinstance ( s , text_type ) : return s else : raise TypeError ( "not expecting type '%s'" % type ( s ) )