pwsm / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

AttributeError: 'NoneType' object has no attribute 'makefile' #96

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
We're getting this error when using as part of Sickbeard:
 File "lib\httplib2\__init__.pyo", line 1106, in request
  File "lib\httplib2\__init__.pyo", line 908, in _request
  File "lib\httplib2\__init__.pyo", line 878, in _conn_request
  File "httplib.pyo", line 972, in getresponse
  File "httplib.pyo", line 330, in __init__
AttributeError: 'NoneType' object has no attribute 'makefile'

I tried applying the latest patch from issue #62 and ended up with this error:
  File "/mnt/data/Sick-Beard/lib/httplib2/__init__.py", line 1106, in request
    (response, new_content) = self._request(conn, authority, uri,
request_uri, method, body, headers, 
redirections, cachekey)
  File "/mnt/data/Sick-Beard/lib/httplib2/__init__.py", line 908, in _request
    (response, content) = self._conn_request(conn, request_uri, method,
body, headers)
  File "/mnt/data/Sick-Beard/lib/httplib2/__init__.py", line 868, in
_conn_request
    if e.errno == errno.ECONNREFUSED: # Connection refused
AttributeError: 'timeout' object has no attribute 'errno'

More details here:
http://code.google.com/p/sickbeard/issues/detail?id=248

Original issue reported on code.google.com by matthew.schick on 6 Apr 2010 at 10:11

GoogleCodeExporter commented 8 years ago
Duplicated with http://code.google.com/p/httplib2/issues/detail?id=62

Original comment by yaohua2...@gmail.com on 14 May 2010 at 2:22

GoogleCodeExporter commented 8 years ago
I don't know if this is the same bug, but this is the behavior I'm getting for 
the 
tip (changeset 144:68f69a80024e) of the default branch: 

>>> from httplib2 import Http
>>> http = Http()
>>> http.request('http://127.0.0.1:5000') # nothing running at this URL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "httplib2/__init__.py", line 1135, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, 
body, headers, redirections, cachekey)
  File "httplib2/__init__.py", line 907, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, 
headers)
  File "httplib2/__init__.py", line 870, in _conn_request
    if e.errno == errno.ECONNREFUSED: # Connection refused
AttributeError: 'error' object has no attribute 'errno'

What's more is that subsequent calls to the same address give the same error 
reported 
by issue #62.  It doesn't seem to have been fixed.

>>> http.request('http://127.0.0.1:5000')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "httplib2/__init__.py", line 1135, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, 
body, headers, redirections, cachekey)
  File "httplib2/__init__.py", line 907, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, 
headers)
  File "httplib2/__init__.py", line 877, in _conn_request
    response = conn.getresponse()
  File "/usr/lib/python2.5/httplib.py", line 926, in getresponse
    method=self._method)
  File "/usr/lib/python2.5/httplib.py", line 324, in __init__
    self.fp = sock.makefile('rb', 0)
AttributeError: 'NoneType' object has no attribute 'makefile'
>>> http.request('http://127.0.0.1:5000')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "httplib2/__init__.py", line 1135, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, 
body, headers, redirections, cachekey)
  File "httplib2/__init__.py", line 907, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, 
headers)
  File "httplib2/__init__.py", line 877, in _conn_request
    response = conn.getresponse()
  File "/usr/lib/python2.5/httplib.py", line 926, in getresponse
    method=self._method)
  File "/usr/lib/python2.5/httplib.py", line 324, in __init__
    self.fp = sock.makefile('rb', 0)
AttributeError: 'NoneType' object has no attribute 'makefile'

An exception is to be expected for this behavior, but we're probably looking 
for a 
more specific one.

Original comment by fridrik...@ru.is on 1 Jun 2010 at 1:38

GoogleCodeExporter commented 8 years ago
This hack fixes it for me. I couldn't see any other way to determine if 
conn.sock (from httplib) is None.

The httplib getresponse() call is unable to handle sock being None, and also 
requires either close() or getresponse() to cleanup conn before it can ever be 
used again.

Original comment by goo...@sa.me.uk on 18 Dec 2010 at 5:09

Attachments:

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 0cff83696d.

Original comment by joe.gregorio@gmail.com on 11 Feb 2011 at 5:29

GoogleCodeExporter commented 8 years ago
Issue 102 has been merged into this issue.

Original comment by joe.gregorio@gmail.com on 11 Feb 2011 at 6:07

GoogleCodeExporter commented 8 years ago
Issue 105 has been merged into this issue.

Original comment by joe.gregorio@gmail.com on 13 Feb 2011 at 3:46

GoogleCodeExporter commented 8 years ago
Issue 101 has been merged into this issue.

Original comment by joe.gregorio@gmail.com on 13 Feb 2011 at 3:47