comparison mercurial/url.py @ 30820:6a70cf94d1b5

py3: replace pycompat.getenv with encoding.environ.get pycompat.getenv returns os.getenvb on py3 which is not available on Windows. This patch replaces them with encoding.environ.get and checks to ensure no new instances of os.getenv or os.setenv are introduced.
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 15 Jan 2017 13:17:05 +0530
parents a520aefb96f1
children 806f9a883b4f
comparison
equal deleted inserted replaced
30819:897726622877 30820:6a70cf94d1b5
13 import os 13 import os
14 import socket 14 import socket
15 15
16 from .i18n import _ 16 from .i18n import _
17 from . import ( 17 from . import (
18 encoding,
18 error, 19 error,
19 httpconnection as httpconnectionmod, 20 httpconnection as httpconnectionmod,
20 keepalive, 21 keepalive,
21 pycompat,
22 sslutil, 22 sslutil,
23 util, 23 util,
24 ) 24 )
25 25
26 httplib = util.httplib 26 httplib = util.httplib
79 return self.passwddb.find_user_password(None, authuri) 79 return self.passwddb.find_user_password(None, authuri)
80 80
81 class proxyhandler(urlreq.proxyhandler): 81 class proxyhandler(urlreq.proxyhandler):
82 def __init__(self, ui): 82 def __init__(self, ui):
83 proxyurl = (ui.config("http_proxy", "host") or 83 proxyurl = (ui.config("http_proxy", "host") or
84 pycompat.osgetenv('http_proxy')) 84 encoding.environ.get('http_proxy'))
85 # XXX proxyauthinfo = None 85 # XXX proxyauthinfo = None
86 86
87 if proxyurl: 87 if proxyurl:
88 # proxy can be proper url or host[:port] 88 # proxy can be proper url or host[:port]
89 if not (proxyurl.startswith('http:') or 89 if not (proxyurl.startswith('http:') or
97 # see if we should use a proxy for this url 97 # see if we should use a proxy for this url
98 no_list = ["localhost", "127.0.0.1"] 98 no_list = ["localhost", "127.0.0.1"]
99 no_list.extend([p.lower() for 99 no_list.extend([p.lower() for
100 p in ui.configlist("http_proxy", "no")]) 100 p in ui.configlist("http_proxy", "no")])
101 no_list.extend([p.strip().lower() for 101 no_list.extend([p.strip().lower() for
102 p in pycompat.osgetenv("no_proxy", '').split(',') 102 p in encoding.environ.get("no_proxy", '').split(',')
103 if p.strip()]) 103 if p.strip()])
104 # "http_proxy.always" config is for running tests on localhost 104 # "http_proxy.always" config is for running tests on localhost
105 if ui.configbool("http_proxy", "always"): 105 if ui.configbool("http_proxy", "always"):
106 self.no_list = [] 106 self.no_list = []
107 else: 107 else: