From cc66feac09353311492015f1f8a6f8e6c7ccab8f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 1 Aug 2015 00:57:34 +0200 Subject: [PATCH] Handle invalid history timestamps. --- qutebrowser/completion/models/urlmodel.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qutebrowser/completion/models/urlmodel.py b/qutebrowser/completion/models/urlmodel.py index 03f55e3ac..2da1d0b71 100644 --- a/qutebrowser/completion/models/urlmodel.py +++ b/qutebrowser/completion/models/urlmodel.py @@ -23,7 +23,7 @@ import datetime from PyQt5.QtCore import pyqtSlot, Qt -from qutebrowser.utils import objreg, utils, qtutils +from qutebrowser.utils import objreg, utils, qtutils, log from qutebrowser.completion.models import base from qutebrowser.config import config @@ -80,7 +80,14 @@ class UrlCompletionModel(base.BaseCompletionModel): fmt = config.get('completion', 'timestamp-format') if fmt is None: return '' - return datetime.datetime.fromtimestamp(atime).strftime(fmt) + try: + dt = datetime.datetime.fromtimestamp(atime) + except (ValueError, OSError, OverflowError): + # Different errors which can occur for too large values... + log.misc.error("Got invalid timestamp {}!".format(atime)) + return '(invalid)' + else: + return dt.strftime(fmt) def _add_history_entry(self, entry): """Add a new history entry to the completion."""