Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Httplib2 - AttributeError: 'NoneType' object has no attribute 'makefile'

How do I fix this?
PS: On googling, I found that this is some httplib2 bug but I didn't understand how to use the patches people have 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'  
like image 804
zubinmehta Avatar asked May 18 '26 07:05

zubinmehta


2 Answers

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

There appear to be some dupes logged, or perhaps the same symptom arising from different circumstances:

  • http://code.google.com/p/httplib2/issues/detail?id=101
  • http://code.google.com/p/httplib2/issues/detail?id=102
like image 116
StevenC Avatar answered May 20 '26 20:05

StevenC


You will also get this error if the server you are tying to connect to is not running or is on a different port. Quite a misleading error message, if you ask me.

like image 20
CM Lubinski Avatar answered May 20 '26 20:05

CM Lubinski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!