Fix bytes/string confusion with Logging
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sat, 20 May 2023 00:37:31 +0200
changeset 3811 fcd2826f5c9e
parent 3810 eafb8f000584
child 3812 92e528718733
Fix bytes/string confusion with Logging
runtime/PLCObject.py
--- a/runtime/PLCObject.py	Sat May 20 00:36:41 2023 +0200
+++ b/runtime/PLCObject.py	Sat May 20 00:37:31 2023 +0200
@@ -131,7 +131,8 @@
             msg, = args
         PLCprint(msg)
         if self._LogMessage is not None:
-            return self._LogMessage(level, msg.encode(), len(msg))
+            bmsg = msg.encode()
+            return self._LogMessage(level, bmsg, len(bmsg))
         return None
 
     @RunInMain
@@ -489,7 +490,7 @@
         self.PythonThreadCondLock.release()
 
     def _fail(self, msg):
-        self.LogMessage(0, msg.decode())
+        self.LogMessage(0, msg)
         self.PLCStatus = PlcStatus.Broken
         self.StatusChange()