unstick r374824

Revision 374824

Date:
2019/10/14 21:49:21
Author:
thopre
Revision Log:
[LNT] Fix execfile Python 3 migration

Code change in revision r374687 introduced a memory leak because it
opens a file for reading in order to execute its content but does not
close it. This commit fixes the leak by putting the read and exec into
open's context block.
Files:

Legend:

 
Added
 
Removed
 
Modified
  • lnt/trunk/lnt/server/db/migrate.py

     
    162 162 upgrade_script = schema_migrations[db_version]
    163 163
    164 164 globals = {}
    165 exec(compile(open(upgrade_script).read(), upgrade_script, 'exec'),
    166 globals)
    165 with open(upgrade_script) as f:
    166 exec(compile(f.read(), upgrade_script, 'exec'), globals)
    167 167 upgrade_method = globals['upgrade']
    168 168
    169 169 # Execute the upgrade.
  • lnt/trunk/lnt/server/db/rules_manager.py

     
    66 66 global HOOKS_LOADED
    67 67 for name, path in load_rules().items():
    68 68 globals = {}
    69 exec(compile(open(path).read(), path, 'exec'), globals)
    69 with open(path) as f:
    70 exec(compile(f.read(), path, 'exec'), globals)
    70 71 DESCRIPTIONS[name] = globals['__doc__']
    71 72 for hook_name in HOOKS.keys():
    72 73 if hook_name in globals: