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: capture stderr in utils.call when capture_stdout is True #2076

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

mayeut
Copy link
Member

@mayeut mayeut commented Nov 9, 2024

fix #2074

@mayeut mayeut marked this pull request as draft November 10, 2024 10:45
@mayeut
Copy link
Member Author

mayeut commented Nov 10, 2024

I don't understand why PyPy fails on Windows. Will try reverting the shell part.

@mayeut mayeut changed the title fix: use shell=False for utils.call on Windows & capture stderr fix: capture stderr in utils.call when capture_stdout is True Nov 11, 2024
@mayeut
Copy link
Member Author

mayeut commented Nov 11, 2024

So it works if we keep using shell on Windows which means there are other side effects that I don't understand.
Let's wait at least for a confirmation that it solves the docker issue in #2074

Comment on lines +131 to +139
# workaround platform behaviour differences outlined
# in https://github.com/python/cpython/issues/52803
path_env = env if env is not None else os.environ
path = path_env.get("PATH", None)
executable = shutil.which(args_[0], path=path)
if executable is None:
msg = f"Couldn't find {args_[0]!r} in PATH {path!r}"
raise FatalError(msg)
args_[0] = executable
Copy link
Member Author

Choose a reason for hiding this comment

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

Given shell is still used on Windows, this could just be removed.
The upside if keeping this is that when a CalledProcessError is raised, we get the full path to the executable rather than just the executable name.

@henryiii
Copy link
Contributor

Should we rename this to capture_output? Maybe not right now, but when we are refactoring the utils for 3.0?

@mayeut
Copy link
Member Author

mayeut commented Nov 11, 2024

Should we rename this to capture_output?

That's a good idea for the refactor in 3.0

@joerick
Copy link
Contributor

joerick commented Nov 12, 2024

Looks good. +1 on the rename. Any ideas why the change to shell=False didn't work even when the PATH resolution workaround is employed?

@henryiii henryiii merged commit 6f21f84 into pypa:main Nov 14, 2024
24 checks passed
@mayeut mayeut deleted the rework-call branch November 14, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failed because docker is too old or is not working properly: json.decoder.JSONDecodeError
3 participants