From 777d328ac15d0894e84339596c8d6346e94aa8a0 Mon Sep 17 00:00:00 2001 From: Ron Frederick Date: Tue, 29 Aug 2023 17:41:24 -0700 Subject: [PATCH] Avoid triggering an exception when shutting down the line editor This commit avoids triggering an internal exception when shutting down the line editor which can lead to data loss on exit, especially on Windows. Thanks go to GitHub user jerrbe for reporting this issue. --- asyncssh/editor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/asyncssh/editor.py b/asyncssh/editor.py index d2c9ff9..174cae2 100644 --- a/asyncssh/editor.py +++ b/asyncssh/editor.py @@ -704,8 +704,10 @@ def process_input(self, data: str, datatype: DataType) -> None: self._ring_bell() self._bell_rung = False - self._chan.write(''.join(self._outbuf)) - self._outbuf.clear() + + if self._outbuf: + self._chan.write(''.join(self._outbuf)) + self._outbuf.clear() else: self._session.data_received(data, datatype)