From 2701d51b627275ce240928c80f2ef744736cb921 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 5 May 2015 13:44:20 -0400 Subject: [PATCH] 8541: Crash following update: addon permission issue blocks re-starting gramps There were two issues: 1. attempting to read a new addon file that wasn't readable threw an exception, aborted updating addons 2. global error catching didn't properly handle error code from an OSError for Python3 --- gramps/gen/plug/_pluginreg.py | 14 ++++++++++---- gramps/gui/grampsgui.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gramps/gen/plug/_pluginreg.py b/gramps/gen/plug/_pluginreg.py index b4a20d754..013796429 100644 --- a/gramps/gen/plug/_pluginreg.py +++ b/gramps/gen/plug/_pluginreg.py @@ -1100,10 +1100,16 @@ class PluginRegister(object): continue lenpd = len(self.__plugindata) full_filename = os.path.join(dir, filename) - if sys.version_info[0] < 3: - fd = open(full_filename, "r") - else: - fd = io.open(full_filename, "r", encoding='utf-8') + try: + if sys.version_info[0] < 3: + fd = open(full_filename, "r") + else: + fd = io.open(full_filename, "r", encoding='utf-8') + except Exception as msg: + print(_('ERROR: Failed reading plugin registration %(filename)s') % \ + {'filename' : filename}) + print(msg) + continue stream = fd.read() fd.close() if os.path.exists(os.path.join(os.path.dirname(full_filename), diff --git a/gramps/gui/grampsgui.py b/gramps/gui/grampsgui.py index 35d5df174..45b04dff4 100644 --- a/gramps/gui/grampsgui.py +++ b/gramps/gui/grampsgui.py @@ -378,7 +378,7 @@ def __startgramps(errors, argparser): % e.code, exc_info=True) except OSError as e: quit_now = True - exit_code = e[0] or 1 + exit_code = e.errno or 1 try: fn = e.filename except AttributeError: