def ensure_binary(s, encoding='<STR_LIT:utf-8>', errors='<STR_LIT:strict>'):
if isinstance(s, text_type):<EOL><INDENT>return s.encode(encoding, errors)<EOL><DEDENT>elif isinstance(s, binary_type):<EOL><INDENT>return s<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>" % type(s))<EOL><DEDENT>
Coerce **s** to six.binary_type.

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

    For Python 3:
      - `str` -> encoded to `bytes`
      - `bytes` -> `bytes`