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 #179

Merged
merged 2 commits into from Oct 8, 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 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,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
shell=use_shell,
cwd=build_file_dir,
check=False
)
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
Member

Choose a reason for hiding this comment

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

In this case, maybe concat stderr info too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if it's merged, do I ignore this ?


concat stderr to what ?

to replacement ?
replacement = result.stdout.decode("utf-8").rstrip() + "\n" + result.stderr.decode("utf-8").rstrip()
the order will be changed, and I don't know how to keep original order as it appeared on screen


the original code did not concat stderr

Copy link
Member

Choose a reason for hiding this comment

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

original code do this in sys.stderr.write(p_stderr)

replacement = result.stdout.decode("utf-8").rstrip() + "\n" + result.stderr.decode("utf-8").rstrip()

Maybe put stderr first.

if it's merged, do I ignore this ?

you can do a new PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the original code is redundant:
it captures stderr,
stderr=subprocess.PIPE,
if stderr is not empty string
if p.wait() != 0 or p_stderr:
it writes it back to stderr
sys.stderr.write(p_stderr)
(it was only captured for condition checking)

the new code:
just don't capture it, stderr is written to stderr anyways

assuming replacement(stdout) is also written to stderr,
if you don't capture stderr, you don't have to concat it to stderr


Maybe put stderr first.

I don't see the point of this concatenation, what does it even change ?


cached_command_results[cache_key] = replacement
else:
Expand Down