From d56cbbe768f24dadaa1b699568745857ebcc166f 2015-04-13 23:23:21 From: Matthias Bussonnier Date: 2015-04-13 23:23:21 Subject: [PATCH] Merge pull request #8311 from thedrow/topic/fix-history-crash Avoid crash if the history table cannot be queried for some reason --- diff --git a/IPython/core/history.py b/IPython/core/history.py index 4401980..adae60d 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -70,10 +70,15 @@ def needs_sqlite(f, self, *a, **kw): if sqlite3 is not None: DatabaseError = sqlite3.DatabaseError + OperationalError = sqlite3.OperationalError else: @undoc class DatabaseError(Exception): "Dummy exception when sqlite could not be imported. Should never occur." + + @undoc + class OperationalError(Exception): + "Dummy exception when sqlite could not be imported. Should never occur." @decorator def catch_corrupt_db(f, self, *a, **kw): @@ -83,7 +88,7 @@ def catch_corrupt_db(f, self, *a, **kw): """ try: return f(self, *a, **kw) - except DatabaseError: + except (DatabaseError, OperationalError): if os.path.isfile(self.hist_file): # Try to move the file out of the way base,ext = os.path.splitext(self.hist_file)