summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2014-11-12 13:54:01 -0800
committerJeff Forcier <jeff@bitprophet.org>2014-11-12 13:54:01 -0800
commitb3d703e984f2046f8eb208e3c82f8bf5c7c49d6a (patch)
tree399c6eb788629bc6c78b75933703869a214043db
parenta08149d5f7aea1fcce55223a000ce9018df02961 (diff)
Improve byte/string interactions in debug logging.
Fixes #429
-rw-r--r--paramiko/transport.py2
-rw-r--r--paramiko/util.py9
2 files changed, 6 insertions, 5 deletions
diff --git a/paramiko/transport.py b/paramiko/transport.py
index 4b91a434..296d6eb7 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -1985,7 +1985,7 @@ class Transport (threading.Thread):
always_display = m.get_boolean()
msg = m.get_string()
lang = m.get_string()
- self._log(DEBUG, 'Debug msg: ' + util.safe_string(msg))
+ self._log(DEBUG, 'Debug msg: {0}'.format(util.safe_string(msg)))
def _get_subsystem_handler(self, name):
try:
diff --git a/paramiko/util.py b/paramiko/util.py
index dbcbbae4..542bb218 100644
--- a/paramiko/util.py
+++ b/paramiko/util.py
@@ -115,12 +115,13 @@ def unhexify(s):
def safe_string(s):
- out = ''
+ out = b('')
for c in s:
- if (byte_ord(c) >= 32) and (byte_ord(c) <= 127):
- out += c
+ i = byte_ord(c)
+ if 32 <= i <= 127:
+ out += byte_chr(i)
else:
- out += '%%%02X' % byte_ord(c)
+ out += b('%%%02X' % i)
return out