changeset 29682:b76ea1384bf2

url: drop compatibility wrapper of socket.create_connection() It should be available on Python 2.6+.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 18 Jul 2016 23:12:09 +0900
parents a181dbef8e7f
children bdc81970853d
files mercurial/url.py
diffstat 1 files changed, 1 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- 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