Index: urllib2.py =================================================================== --- urllib2.py (revision 88915) +++ urllib2.py (working copy) @@ -189,7 +189,9 @@ def __init__(self, url, data=None, headers={}, origin_req_host=None, unverifiable=False): # unwrap('') --> 'type://host/path' - self.__original = unwrap(url) + # quote: percent encode url, fixing lame server errors for e.g, + # like space within url paths. + self.__original = quote(unwrap(url), safe="%/:=&?~#+!$,;'@()*[]|") self.type = None # self.__r_type is what's left after doing the splittype self.host = None @@ -373,6 +375,9 @@ def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): # accept a URL or a Request object if isinstance(fullurl, basestring): + # percent encode url, fixing lame server errors for e.g, + # like space within url paths. + fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|") req = Request(fullurl, data) else: req = fullurl