summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2009-10-18 07:07:00 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2009-10-18 07:07:00 (GMT)
commit31802d093f09dbf4be874e72add58b88047faa97 (patch)
treebb4bfcecfbc0d0804166bcfdd98b43b1b2ddbc84 /Lib
parent9039b83c534251d8a28a16ac25fac20c17382945 (diff)
downloadcpython-31802d093f09dbf4be874e72add58b88047faa97.zip
cpython-31802d093f09dbf4be874e72add58b88047faa97.tar.gz
cpython-31802d093f09dbf4be874e72add58b88047faa97.tar.bz2
Fix for issue 7149: a regression in 2.6.3 that causes an exception when
trying to detect proxy settings on OSX.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urllib.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 8b4029d..db8e616 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -1340,6 +1340,8 @@ if sys.platform == 'darwin':
import socket
from fnmatch import fnmatch
+ hostonly, port = splitport(host)
+
def ip2num(ipAddr):
parts = ipAddr.split('.')
parts = map(int, parts)
@@ -1354,6 +1356,8 @@ if sys.platform == 'darwin':
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
@@ -1361,8 +1365,11 @@ if sys.platform == 'darwin':
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:])