Commits

Ronald Oussoren committed ed7dec1

Merged revisions 75482 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
r75482 | ronald.oussoren | 2009-10-18 09:07:00 +0200 (Sun, 18 Oct 2009) | 3 lines

Fix for issue 7149: a regression in 2.6.3 that causes an exception when
trying to detect proxy settings on OSX.
........

  • Participants
  • Parent commits aa53a2d
  • Branches 2.6

Comments (0)

Files changed (2)

File Lib/urllib.py

         import socket
         from fnmatch import fnmatch
 
+        hostonly, port = splitport(host)
+
         def ip2num(ipAddr):
             parts = ipAddr.split('.')
             parts = map(int, parts)
             if proxy_settings['exclude_simple']:
                 return True
 
+        hostIP = None
+
         for value in proxy_settings.get('exceptions', ()):
             # Items in the list are strings like these: *.local, 169.254/16
             if not value: continue
             m = re.match(r"(\d+(?:\.\d+)*)(/\d+)?", value)
             if m is not None:
                 if hostIP is None:
-                    hostIP = socket.gethostbyname(host)
-                    hostIP = ip2num(hostIP)
+                    try:
+                        hostIP = socket.gethostbyname(hostonly)
+                        hostIP = ip2num(hostIP)
+                    except socket.error:
+                        continue
 
                 base = ip2num(m.group(1))
                 mask = int(m.group(2)[1:])
 Library
 -------
 
+- Issue #7149: fix exception in urllib when detecting proxy settings on OSX.
+
 - Issue #7120: logging: Removed import of multiprocessing which is causing
   crash in GAE.