From 8ea47ce365148b1e1e007c2cb0e4d54247ee6c8f Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Wed, 16 Oct 2019 16:29:38 +0200 Subject: [PATCH] gyp: python3 fixes: utf8 decode, use of 'None' in eval PR-URL: https://github.com/nodejs/node-gyp/pull/1925 Reviewed-By: Christian Clauss Reviewed-By: Richard Lau --- gyp/pylib/gyp/generator/make.py | 2 +- gyp/pylib/gyp/input.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gyp/pylib/gyp/generator/make.py b/gyp/pylib/gyp/generator/make.py index bdf7134537..1960536794 100644 --- a/gyp/pylib/gyp/generator/make.py +++ b/gyp/pylib/gyp/generator/make.py @@ -1776,7 +1776,7 @@ 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' % '@:') diff --git a/gyp/pylib/gyp/input.py b/gyp/pylib/gyp/input.py index 6a0a4db964..2973c078fc 100644 --- a/gyp/pylib/gyp/input.py +++ b/gyp/pylib/gyp/input.py @@ -240,7 +240,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 @@ -1094,7 +1094,7 @@ def EvalSingleCondition( else: ast_code = compile(cond_expr_expanded, '', '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: