Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix ParamikoSSHClient.run() so that it works in Python 3.4.1 #347
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.