Skip to content

Commit c379a74

Browse files
authoredAug 22, 2022
fix: node.js debugger adds stderr (but exit code is 0) -> shouldn't throw (#2719)
* fix: node.js debugger adds stderr (but exit code is 0) -> shouldn't throw * input.py: subprocess.Popen() -> subprocess.run()
1 parent 8958ecf commit c379a74

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed
 

‎gyp/pylib/gyp/input.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -961,33 +961,26 @@ def ExpandVariables(input, phase, variables, build_file):
961961
# Fix up command with platform specific workarounds.
962962
contents = FixupPlatformCommand(contents)
963963
try:
964-
p = subprocess.Popen(
964+
# stderr will be printed no matter what
965+
result = subprocess.run(
965966
contents,
966-
shell=use_shell,
967967
stdout=subprocess.PIPE,
968-
stderr=subprocess.PIPE,
969-
stdin=subprocess.PIPE,
968+
shell=use_shell,
970969
cwd=build_file_dir,
970+
check=False
971971
)
972972
except Exception as e:
973973
raise GypError(
974974
"%s while executing command '%s' in %s"
975975
% (e, contents, build_file)
976976
)
977977

978-
p_stdout, p_stderr = p.communicate("")
979-
p_stdout = p_stdout.decode("utf-8")
980-
p_stderr = p_stderr.decode("utf-8")
981-
982-
if p.wait() != 0 or p_stderr:
983-
sys.stderr.write(p_stderr)
984-
# Simulate check_call behavior, since check_call only exists
985-
# in python 2.5 and later.
978+
if result.returncode > 0:
986979
raise GypError(
987980
"Call to '%s' returned exit status %d while in %s."
988-
% (contents, p.returncode, build_file)
981+
% (contents, result.returncode, build_file)
989982
)
990-
replacement = p_stdout.rstrip()
983+
replacement = result.stdout.decode("utf-8").rstrip()
991984

992985
cached_command_results[cache_key] = replacement
993986
else:

0 commit comments

Comments
 (0)
Please sign in to comment.