[FIX] close the opened file when loading a module
authorChristophe Simonis <christophe@cobalt>
Fri, 2 Jan 2009 22:44:12 +0000 (23:44 +0100)
committerChristophe Simonis <christophe@cobalt>
Fri, 2 Jan 2009 22:44:12 +0000 (23:44 +0100)
bzr revid: christophe@cobalt-20090102224412-ye7am97hdx8ib2yi

bin/addons/__init__.py
bin/addons/base/module/wizard/add_new.py

index 7a2bcec..e3d079b 100644 (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)
index d117cea..fc8a5df 100644 (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',