def ensure_bytes(str_or_bytes, encoding='<STR_LIT:utf-8>', errors='<STR_LIT:strict>'):
if isinstance(str_or_bytes, six.text_type):<EOL><INDENT>return str_or_bytes.encode(encoding, errors)<EOL><DEDENT>return str_or_bytes<EOL>
Ensures an input is bytes, encoding if it is a string.