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

Docker environment: check for None on stdout/stderr response #9238

Merged
merged 3 commits into from
May 17, 2022

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented May 17, 2022

Docker returns None if there wasn't anything printed
to stdout/stderr.

Docker returns None if there wasn't anything printed
to stdout/stderr.
@stsewd stsewd requested a review from a team as a code owner May 17, 2022 18:19
@@ -315,8 +315,8 @@ def run(self):
cmd_stdout, cmd_stderr = out
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, you could set defaults at the top -- plus a walrus!

Suggested change
cmd_stdout, cmd_stderr = out
cmd_stdout, cmd_stderr = (out := ("", ""))

If it helps to default cmd_stdout to "" instead of None.

Copy link
Member Author

Choose a reason for hiding this comment

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

This overrides the real output

>>> out = (None, "foo")
>>> cmd_stdout, cmd_stderr = (out := ("", ""))
>>> cmd_stdout
''
>>> cmd_stderr
''

@stsewd stsewd enabled auto-merge (squash) May 17, 2022 18:47
@stsewd stsewd merged commit 30aa370 into main May 17, 2022
@stsewd stsewd deleted the stdouterr-cab-be-none branch May 17, 2022 18:56
@humitos
Copy link
Member

humitos commented May 19, 2022

I think the problem should be fixed in

instead of where it's fixed in this PR.

If output=None or invalid, it returns None. So, in both cases, we want to return "" is seems. I think it's easier to revert this commit and apply this solution which will also remove @ericholscher's concern from #9238

humitos added a commit that referenced this pull request May 23, 2022
humitos added a commit that referenced this pull request May 23, 2022
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.

4 participants