From 3ea9149d121410f977246f87728ca1408cc04c02 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Sun, 10 Sep 2023 16:36:32 +0300 Subject: [PATCH] telnet use memoryview --- other/telnet_console.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/other/telnet_console.py b/other/telnet_console.py index 8f41cc92..b29b85a7 100644 --- a/other/telnet_console.py +++ b/other/telnet_console.py @@ -119,10 +119,10 @@ def _rt(self) -> None: """ while len(self._tx_buf) > 32: # Bulk try: - self._conn.send(self._tx_buf[:32]) + self._conn.send(memoryview(self._tx_buf)[:32]) except BrokenPipeError: self.disconnect() - self._tx_buf = self._tx_buf[32:] + self._tx_buf = memoryview(self._tx_buf)[32:] if len(self._tx_buf): # regular try: self._conn.send(self._tx_buf) @@ -165,7 +165,7 @@ def _rr(self, block=False) -> None: while self.connected: # Will get interrupted by except size = self._conn.recv_into(self._rx_buf, self._maxbuf) if size: - self._ps_buf += self._rx_buf[:size] + self._ps_buf += memoryview(self._rx_buf)[:size] del size except OSError: pass @@ -211,7 +211,7 @@ def read(self, count=None): # many types returned: Bytes, None. else: self._rr(block=count is None) count = len(self._ps_buf) - res = bytes(self._ps_buf[:count]) + res = bytes(memoryview(self._ps_buf)[:count]) self._ps_buf = self._ps_buf[count:] return res else: