[PATCH STABLE] proxy: remove unneeded _set_hostport for compatibility with Python 2.7.7rc1

Yuya Nishihara yuya at tcha.org
Thu May 22 13:55:17 UTC 2014


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1400763926 -32400
#      Thu May 22 22:05:26 2014 +0900
# Branch stable
# Node ID b8bca4e9640673f43e9027c199c25ff828531fe9
# Parent  54d7657d7d1e6a62315eea53f4498657e766bb60
proxy: remove unneeded _set_hostport for compatibility with Python 2.7.7rc1

With Python 2.7.7rc1, "hg pull" through HTTP CONNECT tunnel fails due to the
removal of _set_hostport [1].

      ...
      File "mercurial/url.py", line 372, in https_open
        return self.do_open(self._makeconnection, req)
      ...
      File "mercurial/url.py", line 342, in connect
        _generic_proxytunnel(self)
      File "mercurial/url.py", line 228, in _generic_proxytunnel
        self._set_hostport(self.host, self.port)
    AttributeError: httpsconnection instance has no attribute '_set_hostport'

self._set_hostport(self.host, self.port) should be noop and can be removed
because:

 - _set_hostport() [2] was the function to parse "host:port" string and
   set them to self.host and self.port,
 - and (self.host, self.port) pair should be valid since connect() is called
   prior to _generic_proxytunnel().

 [1]: http://hg.python.org/cpython/rev/568041fd8090
 [2]: http://hg.python.org/cpython/file/3a1db0d2747e/Lib/httplib.py#l721

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -225,7 +225,6 @@ def _generic_proxytunnel(self):
     proxyheaders = dict(
             [(x, self.headers[x]) for x in self.headers
              if x.lower().startswith('proxy-')])
-    self._set_hostport(self.host, self.port)
     self.send('CONNECT %s HTTP/1.0\r\n' % self.realhostport)
     for header in proxyheaders.iteritems():
         self.send('%s: %s\r\n' % header)



More information about the Mercurial-devel mailing list