From f76b777b9f491514cb2c38a601f23f45d89f939f Mon Sep 17 00:00:00 2001 From: Ian Wood Date: Tue, 16 May 2017 15:09:46 +0100 Subject: [PATCH] don't fail if shelf pickle file broken --- senpy/plugins/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/senpy/plugins/__init__.py b/senpy/plugins/__init__.py index b45a7f4..a02465d 100644 --- a/senpy/plugins/__init__.py +++ b/senpy/plugins/__init__.py @@ -96,7 +96,10 @@ class ShelfMixin(object): if not hasattr(self, '_sh') or self._sh is None: self.__dict__['_sh'] = {} if os.path.isfile(self.shelf_file): - self.__dict__['_sh'] = pickle.load(open(self.shelf_file, 'rb')) + try: + self.__dict__['_sh'] = pickle.load(open(self.shelf_file, 'rb')) + except EOFError: + logger.warning('corrupted shelf file!') return self._sh @sh.deleter