From 244e09f57a6670fbdda9979882d81b1d7e40b75c Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Thu, 13 Feb 2014 12:54:23 -0800 Subject: [PATCH] Slightly safer socket.error handling --- paramiko/transport.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/paramiko/transport.py b/paramiko/transport.py index 6aae083..990c9d3 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -1608,7 +1608,10 @@ class Transport (threading.Thread): self.saved_exception = e except socket.error, e: if type(e.args) is tuple: - emsg = '%s (%d)' % (e.args[1], e.args[0]) + if e.args: + emsg = '%s (%d)' % (e.args[1], e.args[0]) + else: # empty tuple, e.g. socket.timeout + emsg = str(e) or repr(e) else: emsg = e.args self._log(ERROR, 'Socket exception: ' + emsg)