Httplib2 - AttributeError: 'NoneType' object does not have the 'makefile' attribute

How to fix it? PS: In googling, I found this to be some httplib2 error, but I did not understand how to use the patches that people provided.

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'  
+3
source share
3 answers

This is a known issue: http://code.google.com/p/httplib2/issues/detail?id=96

It seems that some errors are recorded or perhaps the same symptom arising from different circumstances:

+5
source

, , , . , .

+5

You created an instance HTTPConnectionbut are not associated with anything, so sockit still has the initial meaningNone

Can you post some code that demonstrates this error? What patches do you use / try to use

0
source

Source: https://habr.com/ru/post/1754182/


All Articles