Skip to content

Commit

Permalink
Also fix error type in HTTPSConnectionWithTimeout.
Browse files Browse the repository at this point in the history
Moved msg inline for clarity as well.
  • Loading branch information
cglouch committed Nov 12, 2019
1 parent ec2e60f commit 1251a2e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions python2/httplib2/__init__.py
Expand Up @@ -1162,7 +1162,6 @@ def connect(self):
raise ProxiesUnavailableError(
"Proxy support missing but proxy use was requested!"
)
msg = "getaddrinfo returns an empty list"
if self.proxy_info and self.proxy_info.isgood():
use_proxy = True
proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers = (
Expand Down Expand Up @@ -1244,7 +1243,8 @@ def connect(self):
continue
break
if not self.sock:
raise socket_err or socket.error(msg)
raise socket_err or socket.error("getaddrinfo returns an empty list")
)


class HTTPSConnectionWithTimeout(httplib.HTTPSConnection):
Expand Down Expand Up @@ -1341,7 +1341,6 @@ def _ValidateCertificateHostname(self, cert, hostname):
def connect(self):
"Connect to a host on a given (SSL) port."

msg = "getaddrinfo returns an empty list"
if self.proxy_info and self.proxy_info.isgood():
use_proxy = True
proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers = (
Expand All @@ -1355,7 +1354,9 @@ def connect(self):

host = self.host
port = self.port


socket_err = None

address_info = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)
for family, socktype, proto, canonname, sockaddr in address_info:
try:
Expand Down Expand Up @@ -1438,7 +1439,8 @@ def connect(self):
raise
except (socket.timeout, socket.gaierror):
raise
except socket.error as msg:
except socket.error as e:
socket_err = e
if self.debuglevel > 0:
print("connect fail: (%s, %s)" % (self.host, self.port))
if use_proxy:
Expand All @@ -1461,7 +1463,7 @@ def connect(self):
continue
break
if not self.sock:
raise socket.error(msg)
raise socket_err or socket.error("getaddrinfo returns an empty list")


SCHEME_TO_CONNECTION = {
Expand Down

0 comments on commit 1251a2e

Please sign in to comment.