[FIX] close the opened file when loading a module

bzr revid: christophe@cobalt-20090102224412-ye7am97hdx8ib2yi
This commit is contained in:
Christophe Simonis 2009-01-02 23:44:12 +01:00
parent 8a6401cfa6
commit aea0ab1d89
2 changed files with 15 additions and 2 deletions

View File

@ -326,7 +326,12 @@ def register_class(m):
try:
zip_mod_path = mod_path + '.zip'
if not os.path.isfile(zip_mod_path):
imp.load_module(m, *imp.find_module(m, [ad, _ad]))
fm = imp.find_module(m, [ad, _ad])
try:
imp.load_module(m, *fm)
finally:
if fm[0]:
fm[0].close()
else:
zimp = zipimport.zipimporter(zip_mod_path)
zimp.load_module(m)

View File

@ -57,7 +57,15 @@ class wizard_install_module(wizard.interface):
terp = mod_obj.get_module_info(module)
if not terp.get('installable', True):
continue
imp.load_module(module, *imp.find_module(module))
# XXX check if this code is correct...
fm = imp.find_module(module)
try:
imp.load_module(module, *fm)
finally:
if fm[0]:
fm[0].close()
mod_id = mod_obj.create(cr, uid, {
'name': module,
'state': 'uninstalled',