def read(console, buffer): char = console.read(1) if char == b'\x08': if buffer: console.write(b'\x08 \x08') buffer.pop() return elif char == b'\n': console.write(b'\n') data = b''.join(buffer) buffer.clear() return data elif len(char) == 1: console.write(char) buffer.append(char) else: return None