diff --git a/gramps/cli/clidbman.py b/gramps/cli/clidbman.py index 5381a7d45..6cf57cf60 100644 --- a/gramps/cli/clidbman.py +++ b/gramps/cli/clidbman.py @@ -159,6 +159,7 @@ class CLIDbManager(object): try: dbmap1.open(fname, META, db.DB_HASH, db.DB_RDONLY) except: + env.close() return "Unknown", "Unknown" version = dbmap1.get('version', default=None) dbmap1.close() @@ -218,6 +219,7 @@ class CLIDbManager(object): if os.path.isfile(path_name): file = open(path_name) name = file.readline().strip() + file.close() (tval, last) = time_val(dirpath) (enable, stock_id) = self.icon_values(dirpath, self.active, diff --git a/gramps/gen/plug/_pluginreg.py b/gramps/gen/plug/_pluginreg.py index e6154384e..bb7d2fabb 100644 --- a/gramps/gen/plug/_pluginreg.py +++ b/gramps/gen/plug/_pluginreg.py @@ -36,7 +36,7 @@ import os import sys import re import traceback -import codecs +import io #------------------------------------------------------------------------- # @@ -1093,13 +1093,16 @@ class PluginRegister(object): full_filename = os.path.join(dir, filename) if sys.version_info[0] < 3: full_filename = full_filename.encode(glocale.getfilesystemencoding()) + fd = open(full_filename, "r") + else: + fd = io.open(full_filename, 'r', encoding = 'utf-8') + stream = fd.read() + fd.close() local_gettext = glocale.get_addon_translator(full_filename).gettext try: #execfile(full_filename, - exec(compile(codecs.open(full_filename, 'r', 'utf-8').read(), - full_filename, 'exec'), - make_environment(_=local_gettext), - {}) + exec (compile(stream, full_filename, 'exec'), + make_environment(_=local_gettext), {}) except ValueError as msg: print(_('ERROR: Failed reading plugin registration %(filename)s') % \ {'filename' : filename})