Skip to content

Commit

Permalink
Merge pull request #541 from davidt/compiler-stdout-unbound
Browse files Browse the repository at this point in the history
Fix an UnboundLocalError if a compiler fails.
  • Loading branch information
davidt committed Feb 22, 2016
2 parents 0db06ec + d0d53a4 commit 76da062
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pipeline/compilers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def execute_command(self, command, cwd=None, stdout_captured=None):
else:
argument_list.extend(flattening_arg)

stdout = None
try:
# We always catch stdout in a file, but we may not have a use for it.
temp_file_container = cwd or os.path.dirname(stdout_captured or "") or os.getcwd()
Expand All @@ -135,7 +136,8 @@ def execute_command(self, command, cwd=None, stdout_captured=None):
raise CompilerError(e)
finally:
# Decide what to do with captured stdout.
if stdout_captured:
os.rename(stdout.name, os.path.join(cwd or os.curdir, stdout_captured))
else:
os.remove(stdout.name)
if stdout:
if stdout_captured:
os.rename(stdout.name, os.path.join(cwd or os.curdir, stdout_captured))
else:
os.remove(stdout.name)

0 comments on commit 76da062

Please sign in to comment.