Runtime: py3 fix forcing of STRING
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 20 Jul 2023 16:16:05 +0200
changeset 3823 a95b5ee1a0ea
parent 3822 d311880b9d15
child 3824 5f0b02ab500c
Runtime: py3 fix forcing of STRING
runtime/typemapping.py
--- a/runtime/typemapping.py	Tue Jun 20 15:05:21 2023 +0200
+++ b/runtime/typemapping.py	Thu Jul 20 16:16:05 2023 +0200
@@ -43,7 +43,7 @@
     "BYTE":       _t(c_uint8),
     "STRING":     (IEC_STRING,
                    lambda x: x.body[:x.len],
-                   lambda t, x: t(len(x), x)),
+                   lambda t, x: t(len(x), x.encode() if type(x)==str else x)),
     "INT":        _t(c_int16),
     "UINT":       _t(c_uint16),
     "WORD":       _t(c_uint16),