I have a buffer of strings, such as:

["apple", "banana\n", "strawberry"]

The idea is to flush the buffer from left-to-right until either the buffer is empty, or a flushed item contains "\n"

I have a loop similar to the following:

while True:
    if len(buffer) <= 0:
    elem = buffer.flush(1)
    if `\n`in elem:

The actual code is more complicated and the loop never terminates. I can't figure out why.
The code is located here. The infinite loop is inside the write_line method on lines 647 to 658.

0 Answers