PYTHON-964 - Raise ConnectionFailures properly when connecting to Unix-domain sockets.

This commit is contained in:
Luke Lovett 2015-07-09 11:46:20 -07:00
parent 8fd0da832a
commit 70be0d8911

View File

@ -51,7 +51,11 @@ except ImportError:
def _raise_connection_failure(address, error):
"""Convert a socket.error to ConnectionFailure and raise it."""
host, port = address
msg = '%s:%d: %s' % (host, port, error)
# If connecting to a Unix socket, port will be None.
if port is not None:
msg = '%s:%d: %s' % (host, port, error)
else:
msg = '%s: %s' % (host, error)
if isinstance(error, socket.timeout):
raise NetworkTimeout(msg)
else: