From aea0ab1d893aa1ee35b1da6062ba4bb66eb1d24d Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 2 Jan 2009 23:44:12 +0100 Subject: [PATCH] [FIX] close the opened file when loading a module bzr revid: christophe@cobalt-20090102224412-ye7am97hdx8ib2yi --- bin/addons/__init__.py | 7 ++++++- bin/addons/base/module/wizard/add_new.py | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 7a2bcec1710..e3d079b39d8 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -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) diff --git a/bin/addons/base/module/wizard/add_new.py b/bin/addons/base/module/wizard/add_new.py index d117ceacff2..fc8a5df071b 100644 --- a/bin/addons/base/module/wizard/add_new.py +++ b/bin/addons/base/module/wizard/add_new.py @@ -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',