From 21da1ed15b39620ddc0254743609d760f4c22137 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 15 Jan 2016 22:22:35 +0000 Subject: [PATCH] Fix ResourceWarning about unclosed file in use_lldb_suite_root.py. llvm-svn: 257945 --- lldb/scripts/Python/use_lldb_suite.py | 9 ++++++--- lldb/scripts/use_lldb_suite.py | 9 ++++++--- lldb/test/use_lldb_suite.py | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lldb/scripts/Python/use_lldb_suite.py b/lldb/scripts/Python/use_lldb_suite.py index 63a098cea220..f3e358af143b 100644 --- a/lldb/scripts/Python/use_lldb_suite.py +++ b/lldb/scripts/Python/use_lldb_suite.py @@ -17,6 +17,9 @@ def find_lldb_root(): lldb_root = find_lldb_root() if lldb_root is not None: import imp - module = imp.find_module("use_lldb_suite_root", [lldb_root]) - if module is not None: - imp.load_module("use_lldb_suite_root", *module) + fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root]) + try: + imp.load_module("use_lldb_suite_root", fp, pathname, desc) + finally: + if fp: + fp.close() diff --git a/lldb/scripts/use_lldb_suite.py b/lldb/scripts/use_lldb_suite.py index 63a098cea220..f3e358af143b 100644 --- a/lldb/scripts/use_lldb_suite.py +++ b/lldb/scripts/use_lldb_suite.py @@ -17,6 +17,9 @@ def find_lldb_root(): lldb_root = find_lldb_root() if lldb_root is not None: import imp - module = imp.find_module("use_lldb_suite_root", [lldb_root]) - if module is not None: - imp.load_module("use_lldb_suite_root", *module) + fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root]) + try: + imp.load_module("use_lldb_suite_root", fp, pathname, desc) + finally: + if fp: + fp.close() diff --git a/lldb/test/use_lldb_suite.py b/lldb/test/use_lldb_suite.py index 63a098cea220..f3e358af143b 100644 --- a/lldb/test/use_lldb_suite.py +++ b/lldb/test/use_lldb_suite.py @@ -17,6 +17,9 @@ def find_lldb_root(): lldb_root = find_lldb_root() if lldb_root is not None: import imp - module = imp.find_module("use_lldb_suite_root", [lldb_root]) - if module is not None: - imp.load_module("use_lldb_suite_root", *module) + fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root]) + try: + imp.load_module("use_lldb_suite_root", fp, pathname, desc) + finally: + if fp: + fp.close()