From e5c065416f9666745e03d2c647736a5c2037fb1e Mon Sep 17 00:00:00 2001 From: Kashiko Koibumi Date: Thu, 30 May 2024 01:49:57 +0900 Subject: [PATCH] fix types --- src/class_objectProcessor.py | 2 +- src/helper_msgcoding.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index 3b555257..a260df76 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -1055,7 +1055,7 @@ class objectProcessor(threading.Thread): logger.info('ackdata checksum wrong. Not sending ackdata.') return False command = command.rstrip(b'\x00') - if command != 'object': + if command != b'object': return False return True diff --git a/src/helper_msgcoding.py b/src/helper_msgcoding.py index 62214525..bddb535c 100644 --- a/src/helper_msgcoding.py +++ b/src/helper_msgcoding.py @@ -2,7 +2,6 @@ Message encoding end decoding functions """ -import string import zlib import messagetypes @@ -100,14 +99,14 @@ class MsgDecode(object): def decodeExtended(self, data): """Handle extended encoding""" dc = zlib.decompressobj() - tmp = "" + tmp = b"" while len(tmp) <= config.safeGetInt("zlib", "maxsize"): try: got = dc.decompress( data, config.safeGetInt("zlib", "maxsize") + 1 - len(tmp)) # EOF - if got == "": + if got == b"": break tmp += got data = dc.unconsumed_tail @@ -143,7 +142,7 @@ class MsgDecode(object): def decodeSimple(self, data): """Handle simple encoding""" - bodyPositionIndex = string.find(data, '\nBody:') + bodyPositionIndex = data.find(b'\nBody:') if bodyPositionIndex > 1: subject = data[8:bodyPositionIndex] # Only save and show the first 500 characters of the subject. @@ -151,10 +150,10 @@ class MsgDecode(object): subject = subject[:500] body = data[bodyPositionIndex + 6:] else: - subject = '' + subject = b'' body = data # Throw away any extra lines (headers) after the subject. if subject: subject = subject.splitlines()[0] - self.subject = subject - self.body = body + self.subject = subject.decode("utf-8", "replace") + self.body = body.decode("utf-8", "replace")