def read_until(b, terminator):
    """Read bytes until the given terminator byte.

    Return the bytes, excluding the terminator byte."""
    bs = bytearray()
    byte = b.read(1)

    while byte != terminator:
        bs.extend(byte)
        byte = b.read(1)

    return bs