def _cli_bytes_from_str(text):
    """
    Python 2/3 compatibility function to ensure that what is sent on the command line
    is converted into bytes. In Python 2 this is a no-op.
    """
    if isinstance(text, bytes):
        return text
    else:
        return text.encode("utf-8", errors="surrogateescape")