Fix ParamikoSSHClient.run() so that it works in Python 3.4.1 #347
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was trying to do the following using apache-libcloud==0.15.1 on Python 3.4.1:
The deploy_node would work fine in Python 2.7.6 but failed when I switched to Python 3,4,1 with the following:
After instrumenting the code to print more informative stack traces, I located the source of the Exception, which was in ParamikoSSHClient.run(). The code where a data chunk is obtained from chan.recv() returns a bytes object in Python 3, where it presumably returns a descendant of basestring in Python 2. This object is then passed to stdout.write() (or stderr.write), which blows up because it's not a stringy value.
My change decodes the bytes into strings as they are passed into those write() methods.
This change made deploy_node() work in my code for Python 3.4.1. I'm not sure if the same type of bug exists elsewhere, but this fix is what I needed to unblock myself.
Thanks for the excellent library, and I hope this helps.