Mercurial > hg-stable
changeset 37103:9e6d3465f17e
url: make logginghttphandler compatible with Python 2.7.6
There wasn't a usable hook point in httplib, so we have to replace connect()
to wrap the socket before self._tunnel().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 24 Mar 2018 13:02:27 +0900 |
parents | 6ca5f825a0ca |
children | 656ac240f392 |
files | mercurial/url.py |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/url.py Sat Mar 24 14:24:32 2018 +0900 +++ b/mercurial/url.py Sat Mar 24 13:02:27 2018 +0900 @@ -12,6 +12,7 @@ import base64 import os import socket +import sys from .i18n import _ from . import ( @@ -304,6 +305,16 @@ keepalive.HTTPConnection.__init__(self, *args, **kwargs) self._create_connection = createconn + if sys.version_info < (2, 7, 7): + # copied from 2.7.14, since old implementations directly call + # socket.create_connection() + def connect(self): + self.sock = self._create_connection((self.host, self.port), + self.timeout, + self.source_address) + if self._tunnel_host: + self._tunnel() + class logginghttphandler(httphandler): """HTTP handler that logs socket I/O.""" def __init__(self, logfh, name, observeropts):