aiorepl: Ignore duplicate LFLF after converting CRLF from Windows.

The regular REPL uses the uncooked input, but aiorepl reads from sys.stdin
which is cooked. The result is that if the client sends a CRLF, aiorepl
will see LFLF.

This ignores a second LF in quick succession from the first.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
pull/571/head
sandyscott 2022-10-28 11:46:52 +01:00 zatwierdzone przez Jim Mussared
rodzic 50b7aca171
commit d6eb5b6f7e
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -110,7 +110,12 @@ async def task(g=None, prompt="--> "):
t = time.ticks_ms()
if c < 0x20 or c > 0x7E:
if c == 0x0A:
# CR
# LF
# If the previous character was also LF, and was less
# than 20 ms ago, this was likely due to CRLF->LFLF
# conversion, so ignore this linefeed.
if pc == 0x0A and time.ticks_diff(t, pt) < 20:
continue
sys.stdout.write("\n")
if cmd:
# Push current command.