0
我正在使用python 3.2.2。如果我嘗試做:python urllib.request.urlopen不遵循重定向
urllib.request.urlopen('https://pypi.python.org/simple/babel')
我獲得以下錯誤信息:
Traceback (most recent call last):
File "solver.py", line 93, in <module>
generateMetadata('babel')
File "solver.py", line 76, in generateMetadata
linklist = parseURL(name)
File "solver.py", line 20, in parseURL
resp = opener.open(REP_URL+name+'/')
File "/usr/lib/python3.2/urllib/request.py", line 375, in open
response = meth(req, response)
File "/usr/lib/python3.2/urllib/request.py", line 487, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.2/urllib/request.py", line 407, in error
result = self._call_chain(*args)
File "/usr/lib/python3.2/urllib/request.py", line 347, in _call_chain
result = func(*args)
File "/usr/lib/python3.2/urllib/request.py", line 560, in http_error_302
headers, fp)
urllib.error.HTTPError: HTTP Error 301: Moved Permanently - Redirection to url '/simple/Babel' is not allowed
搜索我發現,它會自動處理重定向後。
我不能與Python 3.2.3重現此。 – 2013-03-19 13:57:47
就在此之前,異常是'if urlparts.scheme not in'('http','https','ftp',''):'。您的網址必須是狡猾的,請檢查它是否使用了正確的方案。 – 2013-03-19 14:04:42
我測試了python 3.2.3和3.3的相同行,並且都工作。這不可能是我碰到了一個只存在於我的顛覆中的bug,可以嗎? – WeGi 2013-03-19 14:12:34