Mi Zou added the comment: while urllib following the redirection(302): http.client.HTTPConnection.putrequest raise an error: #---------------------------------------------------------- ... File "D:\Program Files\Python32\lib\http\client.py", line 1004, in _send_request self.putrequest(method, url, **skips) File "D:\Program Files\Python32\lib\http\client.py", line 868, in putrequest self._output(request.encode('ascii')) UnicodeEncodeError: 'ascii' codec can't encode characters in position 108-111: ordinal not in range(128) #---------------------------------------------------------- in the sourcode i found that: at line 811
def putrequest(self, method, url, skip_host=0,skip_accept_en...) ... the argument url may be a unicode,and it was unquoted.. ----------------------------note---------------------------------------- in my case: ... purl="http://bbs.dospy.com/1111258attachdown.php?aid=14361277&bbsid=349" req=urllib.request.Request(purl,headers=headers) response=urllib.request.urlopen(req) ... then,the http serve redirect me to a file download url... and the url contains some Chinese word.... i have print out the argument url: /f/1ba1f70606223af2aa5c3aeff6c6a46a/511f7b4c/day_111015/20111015_5949e996881b2e28403d26Ch6dOfj6LZ.rar/p/ÒâÁÖ03-08.part1.rar ---------- resolution: invalid -> status: closed -> open _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17214> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com