3

我该如何解决?
PS:在谷歌上,我发现这是一些 httplib2 错误,但我不明白如何使用人们提供的补丁。

Traceback (most recent call last):  
  File "alt_func.py", line 18, in <module>  
    func(code)
  File "alt_func.py", line 9, in func
    resp, content = h.request(url_string, "GET", headers={'Referer': referer})  
  File "/usr/lib/pymodules/python2.6/httplib2/__init__.py", line 1099, in request  
    (response, new_content) = self._request(conn, authority, uri, request_uri, method,     body, headers, redirections, cachekey)  
  File "/usr/lib/pymodules/python2.6/httplib2/__init__.py", line 901, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)  
  File "/usr/lib/pymodules/python2.6/httplib2/__init__.py", line 871, in _conn_request  
    response = conn.getresponse()  
  File "/usr/lib/python2.6/httplib.py", line 984, in getresponse  
    method=self._method)  
  File "/usr/lib/python2.6/httplib.py", line 330, in __init__  
    self.fp = sock.makefile('rb', 0)  
AttributeError: 'NoneType' object has no attribute 'makefile'  
4

3 回答 3

5

如果您要连接的服务器未运行或位于不同的端口上,您也会收到此错误。如果你问我,这是一个误导性的错误信息。

于 2010-10-29T23:42:09.470 回答
5

这是一个已知问题:http ://code.google.com/p/httplib2/issues/detail?id=96

似乎记录了一些欺骗行为,或者可能是不同情况引起的相同症状:

于 2010-08-12T21:20:04.470 回答
0

您已经创建了一个HTTPConnection实例,但它没有连接到任何东西,所以sock仍然具有初始值None

您可以发布一些显示此故障的代码吗?您正在使用/尝试使用哪些补丁

于 2010-07-12T06:49:27.573 回答