From bb9433e98874fe93a1b3f34848c74050fe9e58af Mon Sep 17 00:00:00 2001 From: nfnty Date: Sat, 25 Feb 2017 11:05:20 +0100 Subject: gui.widgets.console.Console: Don't crash when parsing corrupt history file Fixes #817 --- ranger/gui/widgets/console.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index cc595230..2d905f62 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -47,8 +47,12 @@ class Console(Widget): # pylint: disable=too-many-instance-attributes,too-many- except OSError as ex: self.fm.notify('Failed to read history file', bad=True, exception=ex) else: - for line in fobj: - self.history.add(line[:-1]) + try: + for line in fobj: + self.history.add(line[:-1]) + except UnicodeDecodeError as ex: + self.fm.notify('Failed to parse corrupt history file', + bad=True, exception=ex) fobj.close() self.history_backup = History(self.history) -- cgit 1.4.1-2-gfad0