switch to pickle from cPickle python3
authorGP Orcullo <kinsamanka@gmail.com>
Fri, 28 Oct 2022 15:19:24 +0800
branchpython3
changeset 3758 bc71b19b45ff
parent 3757 814595c0ea16
child 3759 f713566d5d01
switch to pickle from cPickle
BeremizIDE.py
IDEFrame.py
controls/TextCtrlAutoComplete.py
--- a/BeremizIDE.py	Fri Oct 28 14:58:25 2022 +0800
+++ b/BeremizIDE.py	Fri Oct 28 15:19:24 2022 +0800
@@ -25,6 +25,7 @@
 
 
 import os
+import pickle
 import sys
 import shutil
 import time
@@ -32,7 +33,6 @@
 from time import time as gettime
 from threading import Lock, Timer, currentThread
 
-from six.moves import cPickle
 import wx.lib.buttons
 import wx.lib.statbmp
 import wx.stc
@@ -822,7 +822,9 @@
         return OnMenu
 
     def GetConfigEntry(self, entry_name, default):
-        return cPickle.loads(str(self.Config.Read(entry_name, cPickle.dumps(default))))
+        return pickle.loads(self.Config.Read(entry_name,
+                                             pickle.dumps(default,
+                                                          0).decode()).encode())
 
     def ResetConnectionStatusBar(self):
         for field in range(self.ConnectionStatusBar.GetFieldsCount()):
@@ -848,8 +850,11 @@
             recent_projects.remove(projectpath)
         if not err:
             recent_projects.insert(0, projectpath)
-        self.Config.Write("RecentProjects", cPickle.dumps(
-            list(map(EncodeFileSystemPath, recent_projects[:MAX_RECENT_PROJECTS]))))
+        self.Config.Write("RecentProjects",
+                          pickle.dumps(
+                              list(map(EncodeFileSystemPath,
+                                       recent_projects[:MAX_RECENT_PROJECTS])),
+                              0))
         self.Config.Flush()
 
     def ResetPerspective(self):
--- a/IDEFrame.py	Fri Oct 28 14:58:25 2022 +0800
+++ b/IDEFrame.py	Fri Oct 28 15:19:24 2022 +0800
@@ -29,7 +29,6 @@
 import wx
 import wx.grid
 import wx.aui
-from six.moves import cPickle
 
 from editors.EditorPanel import EditorPanel
 from editors.SFCViewer import SFC_Viewer
@@ -880,7 +879,7 @@
     def RestoreLastState(self):
         frame_size = None
         if self.Config.HasEntry("framesize"):
-            frame_size = cPickle.loads(str(self.Config.Read("framesize")))
+            frame_size = pickle.loads(self.Config.Read("framesize").encode())
 
         if frame_size is None:
             self.Maximize()
@@ -889,7 +888,7 @@
 
     def SaveLastState(self):
         if not self.IsMaximized():
-            self.Config.Write("framesize", cPickle.dumps(self.GetClientSize()))
+            self.Config.Write("framesize", pickle.dumps(self.GetClientSize(), 0))
         elif self.Config.HasEntry("framesize"):
             self.Config.DeleteEntry("framesize")
 
--- a/controls/TextCtrlAutoComplete.py	Fri Oct 28 14:58:25 2022 +0800
+++ b/controls/TextCtrlAutoComplete.py	Fri Oct 28 15:19:24 2022 +0800
@@ -23,8 +23,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 
-
-from six.moves import cPickle
+import pickle
 import wx
 
 MAX_ITEM_COUNT = 10
@@ -198,10 +197,12 @@
     def OnControlChanged(self, event):
         res = self.GetValue()
         config = wx.ConfigBase.Get()
-        listentries = cPickle.loads(str(config.Read(self.element_path, cPickle.dumps([]))))
+        listentries = pickle.loads(config.Read(self.element_path,
+                                               pickle.dumps([], 0).decode()
+                                              ).encode())
         if res and res not in listentries:
             listentries = (listentries + [res])[-MAX_ITEM_COUNT:]
-            config.Write(self.element_path, cPickle.dumps(listentries))
+            config.Write(self.element_path, pickle.dumps(listentries, 0))
             config.Flush()
             self.SetChoices(listentries)
         self.DismissListBox()