From 4aa6fa1ce2d1af4da211693a4c3223c1d169772e 2007-12-31 13:05:11 From: vivainio Date: 2007-12-31 13:05:11 Subject: [PATCH] check history length before attempting to access old members. Closes #189 --- diff --git a/IPython/iplib.py b/IPython/iplib.py index ccbcc46..0f99194 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.3 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 2914 2007-12-31 12:53:16Z vivainio $ +$Id: iplib.py 2915 2007-12-31 13:05:11Z vivainio $ """ #***************************************************************************** @@ -2092,10 +2092,11 @@ want to merge them back into the new files.""" % locals() if self.has_readline: # and some config option is set? try: histlen = self.readline.get_current_history_length() - newhist = self.input_hist_raw[-1].rstrip() - self.readline.remove_history_item(histlen-1) - self.readline.replace_history_item(histlen-2, - newhist.encode(self.stdin_encoding)) + if histlen > 1: + newhist = self.input_hist_raw[-1].rstrip() + self.readline.remove_history_item(histlen-1) + self.readline.replace_history_item(histlen-2, + newhist.encode(self.stdin_encoding)) except AttributeError: pass # re{move,place}_history_item are new in 2.4. else: