Skip to content

Fix ShellOutSSHClient.run() returning stdout as stderr - #2259

Open
abedalawieh wants to merge 1 commit into
apache:trunkfrom
abedalawieh:fix/shellout-ssh-stderr
Open

abedalawieh wants to merge 1 commit into
apache:trunkfrom
abedalawieh:fix/shellout-ssh-stderr

Conversation

@abedalawieh

Copy link
Copy Markdown

Fix ShellOutSSHClient.run() returning stdout as stderr

Description

ShellOutSSHClient._run_remote_shell_command() set stderr_str = cast(str, stdout), so run() returned the command's standard output twice and its standard error was lost. The original code returned (stdout, stderr, child.returncode); the mix-up came in with the cast() calls added for type annotations in bfbe014.

The new test_run_returns_stdout_and_stderr mocks subprocess.Popen and checks both values; it fails on trunk and passes with this change.

Not changed here: ShellOutSSHClient.run() returns bytes from communicate(), while ParamikoSSHClient.run() returns decoded str. Happy to follow up on that separately if you'd like the two to match.

Status

  • done, ready for review

Checklist (tick everything that applies)

  • Code linting (black, isort, flake8 on the changed files)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

_run_remote_shell_command() cast stdout for both values when type
annotations were added, so run() returned the command's standard
output in place of its standard error.
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.

1 participant