def appendnewline(fn):
    """Returns a function that calls the given function and appends an ascii
    newline byte to the result (if the result is not a list or dict). The
    result of the function is also interpreted as bytes.

    :param fn: A callable to be wrapped.
    :return: A callable that invokes fn and appends a newline byte.
    """
    def _decorator(*a, **k):
        r = fn(*a, **k)
        if type(r) not in (list, dict):
            r = bytes(r) + b'\n'
        return r
    return _decorator