From: Senthil Kumaran Date: Sat, 6 Aug 2011 04:27:40 +0000 (+0800) Subject: Fix closes issue12698 - make the no_proxy environment variable handling a bit lenient... X-Git-Tag: v3.2.2rc1~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=89976f1cdc49c909f808f8bb1ec15ac963acbc93;p=thirdparty%2FPython%2Fcpython.git Fix closes issue12698 - make the no_proxy environment variable handling a bit lenient (accomodate spaces in between the items) --- diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 3a806bff1679..ac023740ce63 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -135,7 +135,9 @@ class ProxyTests(unittest.TestCase): proxies = urllib.request.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) - + # List of no_proxies with space. + self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com') + self.assertTrue(urllib.request.proxy_bypass_environment('anotherdomain.com')) class urlopen_HttpTests(unittest.TestCase): """Test urlopen() opening a fake http connection.""" diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 1dda966a23b3..773025a09b3a 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -2265,7 +2265,8 @@ def proxy_bypass_environment(host): # strip port off host hostonly, port = splitport(host) # check if the host ends with any of the DNS suffixes - for name in no_proxy.split(','): + no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')] + for name in no_proxy_list: if name and (hostonly.endswith(name) or host.endswith(name)): return 1 # otherwise, don't bypass