def get_string(stream):
ba = bytearray()<EOL>for c in stream:<EOL><INDENT>if not c:<EOL><INDENT>break<EOL><DEDENT>ba.append(c)<EOL><DEDENT>return bytes(ba)<EOL>
r"""Use this to grab a "string" from a bytearray() stream.

    C's printf() prints until it encounters a null byte (b'\0'). This function behaves the same.

    Positional arguments:
    stream -- bytearray stream of data.

    Returns:
    bytes() instance of any characters from the start of the stream until before the first null byte.