Skip to content

Commit 76da062

Browse files
committed
Merge pull request jazzband#541 from davidt/compiler-stdout-unbound
Fix an UnboundLocalError if a compiler fails.
2 parents 0db06ec + d0d53a4 commit 76da062

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pipeline/compilers/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def execute_command(self, command, cwd=None, stdout_captured=None):
111111
else:
112112
argument_list.extend(flattening_arg)
113113

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

0 commit comments

Comments
 (0)