Mercurial > cpython-lru_cache-weakref
diff Lib/socket.py @ 64534:b2f7cf9c6776
Issue #9792: In case of connection failure, socket.create_connection()
would swallow the exception and raise a new one, making it impossible
to fetch the original errno, or to filter timeout errors. Now the
original error is re-raised.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Tue, 07 Sep 2010 21:05:49 +0000 |
| parents | 03268bf9a256 |
| children | caf0b4b0569e |
line wrap: on
line diff
--- a/Lib/socket.py Tue Sep 07 20:42:19 2010 +0000 +++ b/Lib/socket.py Tue Sep 07 21:05:49 2010 +0000 @@ -297,8 +297,8 @@ An host of '' or port 0 tells the OS to use the default. """ - msg = "getaddrinfo returns an empty list" host, port = address + err = None for res in getaddrinfo(host, port, 0, SOCK_STREAM): af, socktype, proto, canonname, sa = res sock = None @@ -311,9 +311,12 @@ sock.connect(sa) return sock - except error as err: - msg = err + except error as _: + err = _ if sock is not None: sock.close() - raise error(msg) + if err is not None: + raise err + else: + raise error("getaddrinfo returns an empty list")
