Fix some file resource leaks
I.e., files left open when the opening function exits. This is a PyDebug warning. svn: r21149
This commit is contained in:
parent
09a875db11
commit
807512cd05
@ -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,
|
||||
|
@ -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})
|
||||
|
Loading…
Reference in New Issue
Block a user