From 47f37908087ede913effb7dac9c608367024103e 2011-01-10 23:34:02 From: Thomas Kluyver Date: 2011-01-10 23:34:02 Subject: [PATCH] Handle corruption of JSON history file. --- diff --git a/IPython/core/history.py b/IPython/core/history.py index 469047e..69fa176 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -147,7 +147,10 @@ class HistoryManager(object): """Reload the input history from disk file.""" with open(self.hist_file,'rt') as hfile: - hist = json.load(hfile) + try: + hist = json.load(hfile) + except ValueError: # Ignore it if JSON is corrupt. + return self.input_hist_parsed = hist['parsed'] self.input_hist_raw = hist['raw'] if self.shell.has_readline: