From 99bac688af32ca01ea6b78564d44b7713ef9a1a1 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 9 Sep 2020 14:36:38 +0100 Subject: [PATCH] eddn: Tweak replay.jsonl try/except flow * Catch OSError instead of Exception (which is *too* general). * Put the set of self.replaylog in try/else so it only runs when there are no errors. --- plugins/eddn.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index a7cc7a4b..62ebbaa5 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -87,7 +87,7 @@ class EDDN: if sys.platform != 'win32': # open for writing is automatically exclusive on Windows lockf(self.replayfile, LOCK_EX | LOCK_NB) - except Exception: + except OSError: logger.exception('Failed opening "replay.jsonl"') if self.replayfile: self.replayfile.close() @@ -95,8 +95,9 @@ class EDDN: self.replayfile = None return False - self.replaylog = [line.strip() for line in self.replayfile] - return True + else: + self.replaylog = [line.strip() for line in self.replayfile] + return True def flush(self): """