From 622aaf7fb23959e4cf50e5feb37d023bde4e417c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 3 Jan 2009 16:05:08 +0100 Subject: [PATCH] Close file object of find_module from openerp rev1546 --- trytond/modules/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/trytond/modules/__init__.py b/trytond/modules/__init__.py index 4075eb7593..f02ede9e5d 100644 --- a/trytond/modules/__init__.py +++ b/trytond/modules/__init__.py @@ -339,8 +339,14 @@ def register_classes(): break elif os.path.isdir(OPJ(MODULES_PATH, module)): try: - imp.load_module(module, *imp.find_module(module, - [MODULES_PATH])) + mod_file, pathname, description = imp.find_module(module, + [MODULES_PATH]) + try: + imp.load_module(module, mod_file, pathname, description) + finally: + if mod_file is not None: + print "close" + mod_file.close() except ImportError: tb_s = '' for line in traceback.format_exception(*sys.exc_info()): @@ -362,7 +368,13 @@ def register_classes(): ep = EGG_MODULES[module] mod_path = os.path.join(ep.dist.location, *ep.module_name.split('.')[:-1]) - imp.load_module(module, *imp.find_module(module, [mod_path])) + mod_file, pathname, description = imp.find_module(module, + [mod_path]) + try: + imp.load_module(module, mod_file, pathname, description) + finally: + if mod_file is not None: + mod_file.close() else: logging.getLogger('init').error( 'Couldn\'t find module %s' % module)