def cast_bytes(s, encoding='utf8'):  # NOQA
        if isinstance(s, bytes):
            return s
        return str(s).encode(encoding)
cast unicode or bytes to bytes
dataset/ETHPy150Open circus-tent/circus/circus/py3compat.py/cast_bytes