# HG changeset patch # User Andrey Skvortsov # Date 1461846062 -10800 # Node ID 4c645e6b8c98b14dce1c1794f853629348e798cb # Parent d7f474d1021083afeb5dda918a04b19b3f8d6521 fix error if non-latin character was entered in initial value in data type element Traceback (most recent call last): File "/home/beremiz/editors/DataTypeEditor.py", line 575, in OnStructureElementsGridCellChange value = self.StructureElementsTable.GetValue(row, col) File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue return str(value) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) Traceback (most recent call last): File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue return str(value) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) Traceback (most recent call last): File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue return str(value) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) diff -r d7f474d10210 -r 4c645e6b8c98 PLCControler.py --- a/PLCControler.py Thu Apr 28 13:05:57 2016 +0300 +++ b/PLCControler.py Thu Apr 28 15:21:02 2016 +0300 @@ -1972,7 +1972,7 @@ else: element_infos["Type"] = element_type_type.upper() if element.initialValue is not None: - element_infos["Initial Value"] = str(element.initialValue.getvalue()) + element_infos["Initial Value"] = element.initialValue.getvalue() else: element_infos["Initial Value"] = "" infos["elements"].append(element_infos) @@ -1983,7 +1983,7 @@ else basetype_content_type.upper()) if datatype.initialValue is not None: - infos["initial"] = str(datatype.initialValue.getvalue()) + infos["initial"] = datatype.initialValue.getvalue() else: infos["initial"] = "" return infos diff -r d7f474d10210 -r 4c645e6b8c98 editors/DataTypeEditor.py --- a/editors/DataTypeEditor.py Thu Apr 28 13:05:57 2016 +0300 +++ b/editors/DataTypeEditor.py Thu Apr 28 15:21:02 2016 +0300 @@ -74,10 +74,11 @@ return row + 1 colname = self.GetColLabelValue(col, False) value = self.data[row].get(colname, "") + if colname == "Type" and isinstance(value, TupleType): if value[0] == "array": return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "..".join(x), value[2])), value[1]) - return str(value) + return value def SetValue(self, row, col, value): if col < len(self.colnames):