url: always access req._tunnel_host
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 12 Feb 2019 12:13:56 -0800
changeset 41708 d20f1594ff4a
parent 41707 140b542b0e59
child 41709 97e2442a4595
url: always access req._tunnel_host The getattr() was there to handle Python versions before 2.6, which lacked this attribute. We /might/ be able to further delete some code here. However, the behavior here is extremely hard to follow because large parts of this code duplicate code from the Python standard library and it is difficult to understand what is actually needed. Differential Revision: https://phab.mercurial-scm.org/D5950
mercurial/url.py
--- a/mercurial/url.py	Fri Feb 15 13:07:07 2019 -0800
+++ b/mercurial/url.py	Tue Feb 12 12:13:56 2019 -0800
@@ -179,10 +179,10 @@
             return proxyres
         return keepalive.HTTPConnection.getresponse(self)
 
-# general transaction handler to support different ways to handle
-# HTTPS proxying before and after Python 2.6.3.
+# Large parts of this function have their origin from before Python 2.6
+# and could potentially be removed.
 def _generic_start_transaction(handler, h, req):
-    tunnel_host = getattr(req, '_tunnel_host', None)
+    tunnel_host = req._tunnel_host
     if tunnel_host:
         if tunnel_host[:7] not in ['http://', 'https:/']:
             tunnel_host = 'https://' + tunnel_host