Skip to content
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

Bug fix/fix error handling #1925

Closed
wants to merge 7 commits into from
Closed
3 changes: 2 additions & 1 deletion gyp/pylib/gyp/generator/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,8 @@ def WriteMakeRule(self, outputs, inputs, actions=None, comment=None,
# - The multi-output rule will have an do-nothing recipe.

# Hash the target name to avoid generating overlong filenames.
cmddigest = hashlib.sha1(command if command else self.target).hexdigest()

cmddigest = hashlib.sha1((command or self.target).encode('utf-8')).hexdigest()
intermediate = "%s.intermediate" % cmddigest
self.WriteLn('%s: %s' % (' '.join(outputs), intermediate))
self.WriteLn('\t%s' % '@:')
Expand Down
8 changes: 3 additions & 5 deletions gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes,
if check:
build_file_data = CheckedEval(build_file_contents)
else:
build_file_data = eval(build_file_contents, {'__builtins__': None},
build_file_data = eval(build_file_contents, {'__builtins__': {}},
None)
except SyntaxError as e:
e.filename = build_file_path
Expand Down Expand Up @@ -911,9 +911,7 @@ def ExpandVariables(input, phase, variables, build_file):
p_stdout, p_stderr = p.communicate('')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, my preference would be the solution we use elsewhere:

if bytes != str:  # Python 3
    p_stdout = p_stdout.decode('utf-8')
    p_stderr = p_stderr.decode('utf-8')

And then revert the change to line 914.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if p.wait() != 0 or p_stderr:
sys.stderr.write(p_stderr)
# Simulate check_call behavior, since check_call only exists
# in python 2.5 and later.
sys.stderr.write(p_stderr.decode('utf-8'))
raise GypError("Call to '%s' returned exit status %d while in %s." %
(contents, p.returncode, build_file))
replacement = p_stdout.rstrip()
Expand Down Expand Up @@ -1090,7 +1088,7 @@ def EvalSingleCondition(
else:
ast_code = compile(cond_expr_expanded, '<string>', 'eval')
cached_conditions_asts[cond_expr_expanded] = ast_code
if eval(ast_code, {'__builtins__': None}, variables):
if eval(ast_code, {'__builtins__': {}}, variables):
return true_dict
return false_dict
except SyntaxError as e:
Expand Down