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

fix: node.js debugger adds stderr (but exit code is 0) -> shouldn't throw #2719

Merged
merged 2 commits into from Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 7 additions & 14 deletions gyp/pylib/gyp/input.py
Expand Up @@ -961,33 +961,26 @@ 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,
cclauss marked this conversation as resolved.
Show resolved Hide resolved
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
shell=use_shell,
cwd=build_file_dir,
check=False
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
check=False
check=False,
text=True

)
except Exception as e:
raise GypError(
"%s while executing command '%s' in %s"
% (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.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.
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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Add text = True to the run() call and then...

Suggested change
replacement = result.stdout.decode("utf-8").rstrip()
replacement = result.stdout.rstrip()


cached_command_results[cache_key] = replacement
else:
Expand Down