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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
''

else:
cmd_stdout = out
self.output = self.sanitize_output(cmd_stdout)
self.error = self.sanitize_output(cmd_stderr)
self.output = self.sanitize_output(cmd_stdout or "")
self.error = self.sanitize_output(cmd_stderr or "")
cmd_ret = client.exec_inspect(exec_id=exec_cmd['Id'])
self.exit_code = cmd_ret['ExitCode']

Expand Down