From c8aea5aa35825dfe0a1ba5a289a7b488f837fdd7 Mon Sep 17 00:00:00 2001 From: totaam Date: Fri, 4 Nov 2022 23:01:48 +0700 Subject: [PATCH] #3679 we may get memoryviews from compressors backport of 8fef1da7df9b0c004e51765545a978aeedc32bc0 --- xpra/net/protocol.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xpra/net/protocol.py b/xpra/net/protocol.py index 8ddf46aba2..cc34907319 100644 --- a/xpra/net/protocol.py +++ b/xpra/net/protocol.py @@ -590,10 +590,6 @@ def encode(self, packet_in): ti = type(item) if ti in (int, bool, dict, list, tuple): continue - if ti==memoryview: - if self.encoder!="rencodeplus": - packet[i] = packet[i].tobytes() - continue try: l = len(item) except TypeError as e: @@ -605,6 +601,10 @@ def encode(self, packet_in): packet[i] = item ti = type(item) #(it may now be a "Compressed" item and be processed further) + if ti==memoryview: + if self.encoder!="rencodeplus": + packet[i] = packet[i].tobytes() + continue if issubclass(ti, LargeStructure): packet[i] = item.data continue @@ -622,6 +622,8 @@ def encode(self, packet_in): else: #data is small enough, inline it: packet[i] = item.data + if isinstance(item.data, memoryview) and self.encoder!="rencodeplus": + packet[i] = item.data.tobytes() min_comp_size += l size_check += l elif ti==bytes and level>0 and l>LARGE_PACKET_SIZE: