Slightly safer socket.error handling

This commit is contained in:
Jeff Forcier 2014-02-13 12:54:23 -08:00
parent 8003c738ca
commit 244e09f57a
1 changed files with 4 additions and 1 deletions

View File

@ -1608,7 +1608,10 @@ class Transport (threading.Thread):
self.saved_exception = e
except socket.error, e:
if type(e.args) is tuple:
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)