Fix strings displaying as repr(bytes) in debug view.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sat, 20 Jan 2024 11:41:17 +0100
changeset 3886 2adfa4c60bff
parent 3885 22a009561502
child 3887 2df45e4bd500
Fix strings displaying as repr(bytes) in debug view.
controls/DebugVariablePanel/DebugVariableItem.py
runtime/typemapping.py
--- a/controls/DebugVariablePanel/DebugVariableItem.py	Fri Jan 19 19:58:44 2024 +0100
+++ b/controls/DebugVariablePanel/DebugVariableItem.py	Sat Jan 20 11:41:17 2024 +0100
@@ -255,7 +255,7 @@
 
                 if self.VariableType in ["STRING", "WSTRING"]:
                     # String data value is CRC
-                    num_value = (binascii.crc32(value) & STRING_CRC_MASK)
+                    num_value = (binascii.crc32(value.encode()) & STRING_CRC_MASK)
                 elif self.VariableType in ["TIME", "TOD", "DT", "DATE"]:
                     # Numeric value of time type variables
                     # is represented in seconds
--- a/runtime/typemapping.py	Fri Jan 19 19:58:44 2024 +0100
+++ b/runtime/typemapping.py	Sat Jan 20 11:41:17 2024 +0100
@@ -42,7 +42,7 @@
     "USINT":      _t(c_uint8),
     "BYTE":       _t(c_uint8),
     "STRING":     (IEC_STRING,
-                   lambda x: x.body[:x.len],
+                   lambda x: x.body[:x.len].decode(),
                    lambda t, x: t(len(x), x.encode() if type(x)==str else x)),
     "INT":        _t(c_int16),
     "UINT":       _t(c_uint16),