import io


def decode_binary(data, encoding=None, errors=None, newline=None):
    """Decode bytes as though read from a text file"""
    return io.TextIOWrapper(io.BytesIO(data), encoding=encoding or 'utf-8', errors=errors, newline=newline).read()