--- a/BeremizIDE.py Fri Oct 28 14:26:17 2022 +0800
+++ b/BeremizIDE.py Fri Oct 28 14:53:23 2022 +0800
@@ -861,7 +861,7 @@
- defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder"))
+ defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder").encode()) defaultpath = os.path.expanduser("~")
--- a/ConfigTreeNode.py Fri Oct 28 14:26:17 2022 +0800
+++ b/ConfigTreeNode.py Fri Oct 28 14:53:23 2022 +0800
@@ -210,22 +210,22 @@
# generate XML for base XML parameters controller of the confnode
- BaseXMLFile = open(self.ConfNodeBaseXmlFilePath(), 'w')
+ BaseXMLFile = open(self.ConfNodeBaseXmlFilePath(), 'w', encoding='utf-8') BaseXMLFile.write(etree.tostring(
+ encoding='utf-8').decode()) # generate XML for XML parameters controller of the confnode
- XMLFile = open(self.ConfNodeXmlFilePath(), 'w')
+ XMLFile = open(self.ConfNodeXmlFilePath(), 'w', encoding='utf-8') XMLFile.write(etree.tostring(
+ encoding='utf-8').decode()) # Call the confnode specific OnCTNSave method
--- a/IDEFrame.py Fri Oct 28 14:26:17 2022 +0800
+++ b/IDEFrame.py Fri Oct 28 14:53:23 2022 +0800
@@ -98,16 +98,15 @@
def EncodeFileSystemPath(path, use_base64=True):
- path = path.encode(sys.getfilesystemencoding())
- return base64.encodestring(path)
+ path = base64.b64encode(path.encode()).decode() def DecodeFileSystemPath(path, is_base64=True):
- path = base64.decodestring(path)
- return str(path, sys.getfilesystemencoding())
+ path = base64.b64decode(path.encode()).decode() def AppendMenu(parent, help, kind, text, id=wx.ID_ANY):
--- a/PLCControler.py Fri Oct 28 14:26:17 2022 +0800
+++ b/PLCControler.py Fri Oct 28 14:53:23 2022 +0800
@@ -454,8 +454,8 @@
self.NextCompiledProject = self.Copy(self.Project)
program_text = "".join([item[0] for item in self.ProgramChunks])
- programfile = open(filepath, "w")
- programfile.write(program_text.encode("utf-8"))
+ programfile = open(filepath, "w", encoding='utf-8') + programfile.write(program_text) self.ProgramFilePath = filepath
return program_text, errors, warnings
--- a/ProjectController.py Fri Oct 28 14:26:17 2022 +0800
+++ b/ProjectController.py Fri Oct 28 14:53:23 2022 +0800
@@ -806,8 +806,8 @@
plc_file.write(POUsIECCodeContent)
- hasher.update(IECCodeContent)
- hasher.update(POUsIECCodeContent)
+ hasher.update(IECCodeContent.encode()) + hasher.update(POUsIECCodeContent.encode()) self.IECcodeDigest = hasher.hexdigest()
--- a/plcopen/plcopen.py Fri Oct 28 14:26:17 2022 +0800
+++ b/plcopen/plcopen.py Fri Oct 28 14:53:23 2022 +0800
@@ -211,7 +211,7 @@
PLCOpen_v1_xml = PLCOpen_v1_xml.replace(
"http://www.plcopen.org/xml/tc6.xsd",
"http://www.plcopen.org/xml/tc6_0201")
-PLCOpen_v1_xsd = etree.XMLSchema(etree.fromstring(PLCOpen_v1_xml))
+PLCOpen_v1_xsd = etree.XMLSchema(etree.fromstring(PLCOpen_v1_xml.encode())) # XPath for file compatibility process
ProjectResourcesXPath = PLCOpen_XPath("ppx:instances/ppx:configurations/ppx:configuration/ppx:resource")
@@ -301,7 +301,7 @@
def LoadProject(filepath):
- project_file = open(filepath)
+ project_file = open(filepath, encoding='utf-8') project_xml = project_file.read()
return LoadProjectXML(project_xml)
@@ -332,11 +332,11 @@
+ encoding='utf-8').decode() - project_file = open(filepath, 'w')
+ project_file = open(filepath, 'w', encoding='utf-8') project_file.write(content)
--- a/targets/toolchain_gcc.py Fri Oct 28 14:26:17 2022 +0800
+++ b/targets/toolchain_gcc.py Fri Oct 28 14:53:23 2022 +0800
@@ -136,7 +136,7 @@
src = open(os.path.join(self.buildpath, bn)).read()
- newhash = hashlib.md5(src).hexdigest()
+ newhash = hashlib.md5(src.encode()).hexdigest() match = (oldhash == newhash)
--- a/util/ProcessLogger.py Fri Oct 28 14:26:17 2022 +0800
+++ b/util/ProcessLogger.py Fri Oct 28 14:53:23 2022 +0800
@@ -23,7 +23,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -142,7 +141,7 @@
if _debug and self.logger:
self.logger.write("(DEBUG) launching:\n" + self.Command_str + "\n")
- self.Proc = subprocess.Popen(self.Command, **popenargs)
+ self.Proc = subprocess.Popen(self.Command, encoding="utf-8", **popenargs) self.outt = outputThread(
--- a/xmlclass/xmlclass.py Fri Oct 28 14:26:17 2022 +0800
+++ b/xmlclass/xmlclass.py Fri Oct 28 14:53:23 2022 +0800
@@ -1731,7 +1731,7 @@
return etree.QName(self.tag).localname
- return NAMESPACE_PATTERN.sub("", etree.tostring(self, pretty_print=True, encoding='utf-8')).decode('utf-8')
+ return NAMESPACE_PATTERN.sub("", etree.tostring(self, encoding='unicode')) def getElementInfos(self, name, path=None, derived=False):
return {"name": name, "type": TAG, "value": None, "use": None, "children": []}
@@ -1844,7 +1844,7 @@
self.ClassLookup = class_lookup
def LoadXMLString(self, xml_string):
- tree = etree.fromstring(xml_string, self)
+ tree = etree.fromstring(xml_string.encode(), self) if not self.XSDSchema.validate(tree):
error = self.XSDSchema.error_log.last_error
return tree, (error.line, error.message)
@@ -1942,7 +1942,7 @@
factory.etreeNamespaceFormat,
BaseClass[0] if len(BaseClass) == 1 else None,
- etree.XMLSchema(etree.fromstring(xsdstring)))
+ etree.XMLSchema(etree.fromstring(xsdstring.encode()))) class_lookup = XMLElementClassLookUp(factory.ComputedClassesLookUp)
parser.set_element_class_lookup(class_lookup)