--- a/eric6/DebugClients/Python/AsyncFile.py Thu Apr 15 16:52:05 2021 +0200 +++ b/eric6/DebugClients/Python/AsyncFile.py Thu Apr 15 18:11:24 2021 +0200 @@ -10,6 +10,7 @@ import socket import threading +import contextlib from DebugUtilities import prepareJsonCommand @@ -109,10 +110,9 @@ break try: - try: + with contextlib.suppress(UnicodeEncodeError, + UnicodeDecodeError): buf = buf.encode('utf-8', 'backslashreplace') - except (UnicodeEncodeError, UnicodeDecodeError): - pass self.sock.sendall(buf) self.nWriteErrors = 0 except OSError: