[Python-checkins] cpython (2.7): Fix closes issue12698 - make the no_proxy environment variable handling a bit

senthil.kumaran python-checkins at python.org
Sat Aug 6 06:28:52 CEST 2011


http://hg.python.org/cpython/rev/c5a35bcfa3ee
changeset:   71750:c5a35bcfa3ee
branch:      2.7
parent:      71741:5b7e765ce049
user:        Senthil Kumaran <senthil at uthcode.com>
date:        Sat Aug 06 12:24:33 2011 +0800
summary:
  Fix closes issue12698 - make the no_proxy environment variable handling a bit lenient (accomodate spaces in between the items)

files:
  Lib/test/test_urllib.py |  3 +++
  Lib/urllib.py           |  3 ++-
  2 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -114,6 +114,9 @@
         proxies = urllib.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.proxy_bypass_environment('anotherdomain.com'))
 
 
 class urlopen_HttpTests(unittest.TestCase):
diff --git a/Lib/urllib.py b/Lib/urllib.py
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -1366,7 +1366,8 @@
     # 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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list