def lz4_decode(payload):
    # Kafka's LZ4 code has a bug in its header checksum implementation
    header_size = 7
    if isinstance(payload[4], int):
        flg = payload[4]
    else:
        flg = ord(payload[4])
    content_size_bit = ((flg >> 3) & 1)
    if content_size_bit:
        header_size += 8

    # This should be the correct hc
    hc = xxhash.xxh32(payload[4:1-header_size]).digest()[-2:-1]  # pylint: disable-msg=no-member

    munged_payload = b''.join([
        payload[0:header_size-1],
        hc,
        payload[header_size:]
    ])

    cCtx = lz4f.createCompContext()  # pylint: disable-msg=no-member
    data = lz4f.decompressFrame(munged_payload, cCtx)  # pylint: disable-msg=no-member
    return data['decomp']
dataset/ETHPy150Open dpkp/kafka-python/kafka/codec.py/lz4_decode/swapped operands of `-`