Skip to content

Misleading UnboundLocalError exception #157

Description

@Aratz

In pyurdme.py (dev branch) from line 2289:

            try:
                if self.report_level >= 1:  #stderr & stdout to the terminal
                    handle = subprocess.Popen(urdme_solver_cmd)
                else:
                    handle = subprocess.Popen(urdme_solver_cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
                    stdout, stderr = handle.communicate()
                return_code = handle.wait()
            except OSError as e:
                print "Error, execution of solver raised an exception: {0}".format(e)
                print "urdme_solver_cmd = {0}".format(urdme_solver_cmd) #<-- This message should be forwarded as an exception

            if return_code != 0:
                if self.report_level >= 1:
                    try:
                        print stderr, stdout
                    except Exception as e:
                        pass
                print "urdme_solver_cmd = {0}".format(urdme_solver_cmd)
                raise URDMEError("Solver execution failed, return code = {0}".format(return_code))

If an exception is raised by the solver, "return_code" is never initialized which leads to an UnboundLocalError exception (which is misleading since the problem comes from the solver). OSError should be forwarded instead.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions