[Python-checkins] CVS: python/dist/src/Lib urllib.py,1.106,1.107
Jeremy Hylton
python-dev@python.org
Mon, 2 Oct 2000 16:04:05 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv17756/dist/src/Lib
Modified Files:
urllib.py
Log Message:
Provide a clearer error message when urlopen fails because of an
invalid proxy setting.
Minor change to call of unknown_url; always pass data argument
explicitly since data defaults to None.
PEP 42: Add as a feature that urllib handle proxy setting that contain
only the host and port of the proxy.
Index: urllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v
retrieving revision 1.106
retrieving revision 1.107
diff -C2 -r1.106 -r1.107
*** urllib.py 2000/09/24 18:51:25 1.106
--- urllib.py 2000/10/02 23:04:02 1.107
***************
*** 143,152 ****
return addinfourl(fp, headers, fullurl)
type, url = splittype(fullurl)
! if not type: type = 'file'
if self.proxies.has_key(type):
proxy = self.proxies[type]
! type, proxy = splittype(proxy)
! host, selector = splithost(proxy)
url = (host, fullurl) # Signal special case to open_*()
name = 'open_' + type
self.type = type
--- 143,155 ----
return addinfourl(fp, headers, fullurl)
type, url = splittype(fullurl)
! if not type:
! type = 'file'
if self.proxies.has_key(type):
proxy = self.proxies[type]
! type, proxyhost = splittype(proxy)
! host, selector = splithost(proxyhost)
url = (host, fullurl) # Signal special case to open_*()
+ else:
+ proxy = None
name = 'open_' + type
self.type = type
***************
*** 155,160 ****
name = string.join(string.split(name, '-'), '_')
if not hasattr(self, name):
! if data is None:
! return self.open_unknown(fullurl)
else:
return self.open_unknown(fullurl, data)
--- 158,163 ----
name = string.join(string.split(name, '-'), '_')
if not hasattr(self, name):
! if proxy:
! return self.open_unknown_proxy(proxy, fullurl, data)
else:
return self.open_unknown(fullurl, data)
***************
*** 171,174 ****
--- 174,182 ----
type, url = splittype(fullurl)
raise IOError, ('url error', 'unknown url type', type)
+
+ def open_unknown_proxy(self, proxy, fullurl, data=None):
+ """Overridable interface to open unknown URL type."""
+ type, url = splittype(fullurl)
+ raise IOError, ('url error', 'invalid proxy for %s' % type, proxy)
# External interface