]> granicus.if.org Git - python/commitdiff
Fix closes issue12698 - make the no_proxy environment variable handling a bit lenient...
authorSenthil Kumaran <senthil@uthcode.com>
Sat, 6 Aug 2011 04:27:40 +0000 (12:27 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Sat, 6 Aug 2011 04:27:40 +0000 (12:27 +0800)
Lib/test/test_urllib.py
Lib/urllib/request.py

index 3a806bff167994ff6539a95163df580bf4e9edab..ac023740ce63905a5426dba7238c8a28c8da1c46 100644 (file)
@@ -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."""
index 1dda966a23b314b26fae744348569d9df1f2e4c9..773025a09b3a22c05576cc6a2e59e563bc7e6c10 100644 (file)
@@ -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