def asbytes(s):
if not isinstance(s, bytes_types):
if isinstance(s, string_types):
s = b(s)
else:
try:
s = s.asbytes()
except Exception: raise Exception('Unknown type')
return s
Which means that if "asbytes()" raises exceptions for one reason or another, like "Exception: Unknown type <SFTPAttributes: [ size=16 uid=1000 gid=1000 mode=0100644 atime=1449250574 mtime=1449250574 ]>: UnicodeDecodeError('ascii', '-rw-r--r-- 1 1000 1000 16 04 d\xc3\xa9c 17:36 ', 46, 47, 'ordinal not in range(128)')" it gets silently hidden :(
argh, so paramiko has this gem:
def asbytes(s):
raise Exception('Unknown type')
if not isinstance(s, bytes_types):
if isinstance(s, string_types):
s = b(s)
else:
try:
s = s.asbytes()
except Exception:
return s
Which means that if "asbytes()" raises exceptions for one reason or another, like "Exception: Unknown type <SFTPAttributes: [ size=16 uid=1000 gid=1000 mode=0100644 atime=1449250574 mtime=1449250574 ]>: UnicodeDecodeEr ror('ascii' , '-rw-r--r-- 1 1000 1000 16 04 d\xc3\xa9c 17:36 ', 46, 47, 'ordinal not in range(128)')" it gets silently hidden :(