[PATCH] url: drop compatibility wrapper of socket.create_connection()
Yuya Nishihara
yuya at tcha.org
Tue Aug 2 13:02:22 UTC 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1468851129 -32400
# Mon Jul 18 23:12:09 2016 +0900
# Node ID 76f8aecf37ee6a7508a84394b0eb427df9806cd4
# Parent 7eb9ee3e6b148210cb84dace2cb792167238e410
url: drop compatibility wrapper of socket.create_connection()
It should be available on Python 2.6+.
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -151,35 +151,6 @@ def _gen_sendfile(orgsend):
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 @@ if has_https:
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
More information about the Mercurial-devel
mailing list