@@ -832,21 +832,7 @@ def push(self, s, insert_into_history=True):
832
832
self .buffer .append (s )
833
833
834
834
if insert_into_history :
835
- if self .config .hist_length :
836
- histfilename = os .path .expanduser (self .config .hist_file )
837
- oldhistory = self .rl_history .entries
838
- self .rl_history .entries = []
839
- if os .path .exists (histfilename ):
840
- self .rl_history .load (histfilename , getpreferredencoding ())
841
- self .rl_history .append (s )
842
- try :
843
- self .rl_history .save (histfilename , getpreferredencoding (), self .config .hist_length )
844
- except EnvironmentError , err :
845
- self .interact .notify ("Error occured while writing to file %s (%s) " % (histfilename , err .strerror ))
846
- self .rl_history .entries = oldhistory
847
- self .rl_history .append (s )
848
- else :
849
- self .rl_history .append (s )
835
+ self .insert_into_history (s )
850
836
851
837
more = self .interp .runsource ('\n ' .join (self .buffer ))
852
838
@@ -855,6 +841,23 @@ def push(self, s, insert_into_history=True):
855
841
856
842
return more
857
843
844
+ def insert_into_history (self , s ):
845
+ if self .config .hist_length :
846
+ histfilename = os .path .expanduser (self .config .hist_file )
847
+ oldhistory = self .rl_history .entries
848
+ self .rl_history .entries = []
849
+ if os .path .exists (histfilename ):
850
+ self .rl_history .load (histfilename , getpreferredencoding ())
851
+ self .rl_history .append (s )
852
+ try :
853
+ self .rl_history .save (histfilename , getpreferredencoding (), self .config .hist_length )
854
+ except EnvironmentError , err :
855
+ self .interact .notify ("Error occured while writing to file %s (%s) " % (histfilename , err .strerror ))
856
+ self .rl_history .entries = oldhistory
857
+ self .rl_history .append (s )
858
+ else :
859
+ self .rl_history .append (s )
860
+
858
861
def undo (self , n = 1 ):
859
862
"""Go back in the undo history n steps and call reeavluate()
860
863
Note that in the program this is called "Rewind" because I
0 commit comments