Permalink
Browse files

Handle corruption of JSON history file.

  • Loading branch information...
1 parent d0614fc commit 47f37908087ede913effb7dac9c608367024103e @takluyver takluyver committed Jan 10, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 IPython/core/history.py
View
5 IPython/core/history.py
@@ -147,7 +147,10 @@ def reload_history(self):
"""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:

0 comments on commit 47f3790

Please sign in to comment.