From 6e1bf2b760c9f824ee569da955028622336ba27d Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Thu, 11 Oct 2018 15:18:42 +0100 Subject: [PATCH] Define runfiles_path before try so that finally can use it. Otherwise, python will complain the variable has not been initialized, in case ExtractRunFiles throws an exception. Test: m Change-Id: I3d9e3cda5e558436ee4182c44e4345151c031e41 --- python/scripts/stub_template_host.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/scripts/stub_template_host.txt b/python/scripts/stub_template_host.txt index e68621144..213401dce 100644 --- a/python/scripts/stub_template_host.txt +++ b/python/scripts/stub_template_host.txt @@ -41,6 +41,7 @@ def Main(): args = sys.argv[1:] new_env = {} + runfiles_path = None try: runfiles_path = ExtractRunfiles() @@ -82,7 +83,8 @@ def Main(): except: raise finally: - shutil.rmtree(runfiles_path, True) + if runfiles_path is not None: + shutil.rmtree(runfiles_path, True) if __name__ == '__main__': Main()