parameters: (s, encoding="utf-8", errors="strict")
return_statement: return s
docstring: Coerce *s* to `str`.
  
      For Python 2:
        - `unicode` -> encoded to `str`
        - `str` -> `str`
  
      For Python 3:
        - `str` -> `str`
        - `bytes` -> decoded to `str`
docstring_summary: Coerce *s* to `str`.
docstring_tokens: Coerce * s * to str .
function: def ensure_str(s, encoding="utf-8", errors="strict"):
      """Coerce *s* to `str`.
  
      For Python 2:
        - `unicode` -> encoded to `str`
        - `str` -> `str`
  
      For Python 3:
        - `str` -> `str`
        - `bytes` -> decoded to `str`
      """
      if not isinstance(s, (text_type, binary_type)):
          raise TypeError("not expecting type '%s'" % type(s))
      if PY2 and isinstance(s, text_type):
          s = s.encode(encoding, errors)
      elif PY3 and isinstance(s, binary_type):
          s = s.decode(encoding, errors)
      return s
function_tokens: def ensure_str ( s , encoding = "utf-8" , errors = "strict" ) : if not isinstance ( s , ( text_type , binary_type ) ) : raise TypeError ( "not expecting type '%s'" % type ( s ) ) if PY2 and isinstance ( s , text_type ) : s = s . encode ( encoding , errors ) elif PY3 and isinstance ( s , binary_type ) : s = s . decode ( encoding , errors ) return s