@@ -599,17 +599,15 @@ def GetTypeString(self, obj):
599
599
#-------------------------------------------------
600
600
601
601
def SaveHistoryToFile (self ):
602
- # PK TODO: pickle not yet working in Python3
603
- if sys .version_info .major == 2 :
604
- cmdlist = self .CommandHistoryListCtrl .GetAllItems ()
605
- f = open (self .HISTORY_FILENAME , 'w' )
606
- pickle .dump (cmdlist , f )
602
+ cmdlist = self .CommandHistoryListCtrl .GetAllItems ()
603
+ f = open (self .HISTORY_FILENAME , 'wb' )
604
+ pickle .dump (cmdlist , f )
607
605
608
606
def LoadHistoryFromFile (self , fn = HISTORY_FILENAME ):
609
607
Data = []
610
608
if os .path .isfile (fn ):
611
609
try :
612
- Data = pickle .load (open (fn ))
610
+ Data = pickle .load (open (fn , 'rb' ))
613
611
except Exception as error :
614
612
msgdlg = wx .MessageDialog (self , str (error ), "Load History" , wx .OK | wx .ICON_ERROR )
615
613
msgdlg .ShowModal ()
@@ -693,13 +691,13 @@ def TruncateHistoryFile(self):
693
691
# write the command file up to the selected line into the named file
694
692
# fetch any existing list first and append to it
695
693
try :
696
- archlist = pickle .load (open (fn ))
694
+ archlist = pickle .load (open (fn ), 'rb' )
697
695
except IOError :
698
696
archlist = []
699
697
n = 0
700
698
for n in range (choice ):
701
699
archlist .append ( cmdlist [n ] )
702
- pickle .dump ( archlist , open (fn , 'w ' ))
700
+ pickle .dump ( archlist , open (fn , 'wb ' ))
703
701
text = "Your command history was archived to " + fn
704
702
msgdlg = wx .MessageDialog (self , text , title , wx .OK | wx .ICON_INFORMATION )
705
703
msgdlg .ShowModal ()
@@ -836,7 +834,7 @@ def OnViewLogger(self, event):
836
834
def OnLoadWorkspace (self , event ):
837
835
Filepath = py .editor .openSingle (directory = '' ,wildcard = 'IRE Workspace (*.ws)|*.ws|All Files (*.*)|*.*' ).path
838
836
if Filepath :
839
- File = open (Filepath )
837
+ File = open (Filepath , 'rb' )
840
838
LoadWorkspaceFile (self .Shell .interp .locals , File )
841
839
File .close ()
842
840
self .CheckScopeVariables ()
@@ -848,7 +846,7 @@ def OnSaveWorkspace(self, event):
848
846
(name , ext ) = os .path .splitext (Filepath )
849
847
if not ext :
850
848
Filepath += '.ws'
851
- File = open (Filepath ,'w ' )
849
+ File = open (Filepath ,'wb ' )
852
850
SaveWorkspaceToFile (self .Shell .interp .locals , File )
853
851
File .close ()
854
852
0 commit comments