From 60416b82e25000bb3795fe46cb9aa37c624540c7 Mon Sep 17 00:00:00 2001 From: FuPeiJiang <42662615+FuPeiJiang@users.noreply.github.com> Date: Thu, 18 Aug 2022 23:10:13 -0400 Subject: [PATCH 1/2] fix: node.js debugger adds stderr (but exit code is 0) -> shouldn't throw --- pylib/gyp/input.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py index 354958bf..db0af37a 100644 --- a/pylib/gyp/input.py +++ b/pylib/gyp/input.py @@ -979,8 +979,9 @@ def ExpandVariables(input, phase, variables, build_file): p_stdout = p_stdout.decode("utf-8") p_stderr = p_stderr.decode("utf-8") - if p.wait() != 0 or p_stderr: + if p_stderr: sys.stderr.write(p_stderr) + if p.wait() != 0: # Simulate check_call behavior, since check_call only exists # in python 2.5 and later. raise GypError( From 9e75172f82c391924531e7068fc4e7fb46bede01 Mon Sep 17 00:00:00 2001 From: FuPeiJiang <42662615+FuPeiJiang@users.noreply.github.com> Date: Fri, 19 Aug 2022 03:20:56 -0400 Subject: [PATCH 2/2] input.py: subprocess.Popen() -> subprocess.run() --- pylib/gyp/input.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py index db0af37a..d9699a0a 100644 --- a/pylib/gyp/input.py +++ b/pylib/gyp/input.py @@ -961,13 +961,13 @@ def ExpandVariables(input, phase, variables, build_file): # Fix up command with platform specific workarounds. contents = FixupPlatformCommand(contents) try: - p = subprocess.Popen( + # stderr will be printed no matter what + result = subprocess.run( contents, - shell=use_shell, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - stdin=subprocess.PIPE, + shell=use_shell, cwd=build_file_dir, + check=False ) except Exception as e: raise GypError( @@ -975,20 +975,12 @@ def ExpandVariables(input, phase, variables, build_file): % (e, contents, build_file) ) - p_stdout, p_stderr = p.communicate("") - p_stdout = p_stdout.decode("utf-8") - p_stderr = p_stderr.decode("utf-8") - - if p_stderr: - sys.stderr.write(p_stderr) - if p.wait() != 0: - # Simulate check_call behavior, since check_call only exists - # in python 2.5 and later. + if result.returncode > 0: raise GypError( "Call to '%s' returned exit status %d while in %s." - % (contents, p.returncode, build_file) + % (contents, result.returncode, build_file) ) - replacement = p_stdout.rstrip() + replacement = result.stdout.decode("utf-8").rstrip() cached_command_results[cache_key] = replacement else: