Skip to content

Fix an UnboundLocalError if a compiler fails. #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2016

Conversation

davidt
Copy link
Contributor

@davidt davidt commented Feb 17, 2016

Depending on where an exception is raised inside a compiler's
execute_command, the stdout variable may not be assigned. In this case, the
finally handler would fail with an UnboundLocalError, hiding the true cause
of the exception. This change adds a new variable, stdout_name, which is
populated once we've actually created the file. After this, the CompilerError
is successfully raised with the contents of the true error.

Depending on where an exception is raised inside a compiler's
`execute_command`, the `stdout` variable may not be assigned. In this case, the
finally handler would fail with an `UnboundLocalError`, hiding the true cause
of the exception. This change adds a new variable, `stdout_name`, which is
populated once we've actually created the file. After this, the `CompilerError`
is successfully raised with the contents of the true error.
@fdintino
Copy link
Member

A quick note to the maintainer that I included the fix for this in my compiler/compressor unit tests pull request (#531) in commit theatlantic@9d7c6c0 . If this gets merged it will create a merge conflict, so I'll keep an eye out (as that would be relatively easy to resolve).

@cyberdelia
Copy link
Member

Oops. Thanks for the fix.

🏃 🌲

Pull request 531, among many other things, includes a similar fix for the use
of `stdout` before it's been assigned. That implementation is a nicer read, so
I've switched over to it.
davidt added a commit that referenced this pull request Feb 22, 2016
Fix an UnboundLocalError if a compiler fails.
@davidt davidt merged commit 76da062 into jazzband:master Feb 22, 2016
@davidt davidt deleted the compiler-stdout-unbound branch February 22, 2016 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants