diff options
author | Michal Reznik <mreznik@redhat.com> | 2017-09-26 10:32:27 +0200 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2017-09-26 12:07:49 -0700 |
commit | 5aefc0ad37811000dfc2c27ffd6ad040d6971bbd (patch) | |
tree | 6fc75b33b4730c1fbd0bf552909286c74e09a390 | |
parent | 04f62f765a03d045f4abaf69f61f835f2af81125 (diff) |
sftp: fix BytesWarning: str() on a bytes instance
when running the code with python3 we get BytesWarning as what we
receive from hexlify() function is bytes. Use u() from py3compat to
overcome the issue.
Fix: https://github.com/paramiko/paramiko/issues/1074
-rw-r--r-- | paramiko/sftp_client.py | 2 | ||||
-rw-r--r-- | paramiko/sftp_file.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py index ee5ab073..464e031c 100644 --- a/paramiko/sftp_client.py +++ b/paramiko/sftp_client.py @@ -341,7 +341,7 @@ class SFTPClient(BaseSFTP, ClosingContextManager): handle = msg.get_binary() self._log( DEBUG, - 'open(%r, %r) -> %s' % (filename, mode, hexlify(handle))) + 'open(%r, %r) -> %s' % (filename, mode, u(hexlify(handle)))) return SFTPFile(self, handle, mode, bufsize) # Python continues to vacillate about "open" vs "file"... diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index 337cdbeb..028d894a 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -30,7 +30,7 @@ import time from paramiko.common import DEBUG from paramiko.file import BufferedFile -from paramiko.py3compat import long +from paramiko.py3compat import u, long from paramiko.sftp import ( CMD_CLOSE, CMD_READ, CMD_DATA, SFTPError, CMD_WRITE, CMD_STATUS, CMD_FSTAT, CMD_ATTRS, CMD_FSETSTAT, CMD_EXTENDED, @@ -83,7 +83,7 @@ class SFTPFile (BufferedFile): # __del__.) if self._closed: return - self.sftp._log(DEBUG, 'close(%s)' % hexlify(self.handle)) + self.sftp._log(DEBUG, 'close(%s)' % u(hexlify(self.handle))) if self.pipelined: self.sftp._finish_responses(self) BufferedFile.close(self) |