# HG changeset patch # User Yuya Nishihara # Date 1468851129 -32400 # Node ID b76ea1384bf2d536ee48b7c43b156d44b5faa2b6 # Parent a181dbef8e7f3ba15763c4379469c83d7a3167c0 url: drop compatibility wrapper of socket.create_connection() It should be available on Python 2.6+. diff -r a181dbef8e7f -r b76ea1384bf2 mercurial/url.py --- a/mercurial/url.py Sat May 14 14:37:25 2016 +0900 +++ b/mercurial/url.py Mon Jul 18 23:12:09 2016 +0900 @@ -151,35 +151,6 @@ return _sendfile has_https = util.safehasattr(urlreq, 'httpshandler') -if has_https: - try: - _create_connection = socket.create_connection - except AttributeError: - _GLOBAL_DEFAULT_TIMEOUT = object() - - def _create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, - source_address=None): - # lifted from Python 2.6 - - msg = "getaddrinfo returns an empty list" - host, port = address - for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): - af, socktype, proto, canonname, sa = res - sock = None - try: - sock = socket.socket(af, socktype, proto) - if timeout is not _GLOBAL_DEFAULT_TIMEOUT: - sock.settimeout(timeout) - if source_address: - sock.bind(source_address) - sock.connect(sa) - return sock - - except socket.error as msg: - if sock is not None: - sock.close() - - raise socket.error(msg) class httpconnection(keepalive.HTTPConnection): # must be able to send big bundle as stream. @@ -337,7 +308,7 @@ self.cert_file = cert_file def connect(self): - self.sock = _create_connection((self.host, self.port)) + self.sock = socket.create_connection((self.host, self.port)) host = self.host if self.realhostport: # use CONNECT proxy