Closed GoogleCodeExporter closed 9 years ago
I can confirm this bug.
Attached is the patch that fixes this.
Original comment by zelo.z...@gmail.com
on 9 Sep 2009 at 11:20
Attachments:
New patch, the old tried to connect in wrong place and socket.gaierror was not
intercepted.
Original comment by zelo.z...@gmail.com
on 14 Sep 2009 at 1:29
Attachments:
Ubuntu bug on this:
https://bugs.edge.launchpad.net/ubuntu/+source/python-httplib2/+bug/523327
Original comment by hgg...@gmail.com
on 18 Feb 2010 at 7:23
I confirm this bug and that patch by zelo.zejn fixes it. Thank you, zelo.zejn.
Original comment by temotor
on 28 Feb 2010 at 7:02
The patch doesn't fix the problem correctly, it simply forces a new connection
for
each request which breaks keep-alive.
Original comment by zxvdr...@gmail.com
on 9 Mar 2010 at 11:16
Ahem, what keep-alive? If the server refused connection, there is no valid,
connected
connection.
Original comment by zelo.z...@gmail.com
on 9 Mar 2010 at 11:48
This diff fixes the issue for me. It only occurrs for me when an HTTP server
wasn't
listening, one would get the cryptic "'NoneType' object has no attribute
'makefile'"
error message.
With this diff applied, one now receives the correct error "Connection refused"
error
message, which is far less confusing to anyone using this library.
Original comment by jthack...@gmail.com
on 22 Mar 2010 at 3:17
The change for issue 51 caused this bug
(http://code.google.com/p/httplib2/source/detail?r=1457646c54eb).
Original comment by tre...@gmail.com
on 30 Mar 2010 at 8:43
Attached is a proposed fix for this: re-raise the socket error if it is for
"Connection refused". At the least this
restores the behaviour of httplib2 0.4.0. This also should not break the new
keep-alive support.
I'm not sure if special casing errno 61 this way is the correct answer or if it
should be the other way around: i.e.
if the fix for issue 51 should instead have special cased the errno for the
"server closed the connection". It would
be good if jason.davies could respond to that.
Original comment by tre...@gmail.com
on 30 Mar 2010 at 8:49
Attachments:
I created a local patch (not attached) that looks almost identical to yours
tre...,
except for 1 line:
- if e.args[0] == 61: # Connection refused
+ if e.errno == errno.ECONNREFUSED:
I think this is cleaner and more cross-platform.
Original comment by mitacker@gmail.com
on 31 Mar 2010 at 3:42
@mitacker: agreed. On Windows `errno.ECONNREFUSED == 10061` so indeed your's is
a better answer. Also
requires an import. New patch coming.
This new patch includes a patch for python3/httplib2/__init__.py as well.
However the patch there had to be a
little more adventurous in getting the e.errno (see
http://bugs.python.org/issue6471) because the socket.error's
arg is something another socket.error.
Original comment by tre...@gmail.com
on 31 Mar 2010 at 5:05
Attachments:
s/something/sometimes/ in my last comment
Original comment by tre...@gmail.com
on 31 Mar 2010 at 5:06
I should have mentioned that I tested this with: Python 2.6 on Windows, Python
2.6 on Mac and Python 3.1 on
Mac
Original comment by tre...@gmail.com
on 31 Mar 2010 at 5:11
This issue is critical, should not be classified as "Medium" priority. It's
been almost one year and this critical bug
is still in the release. Too bad.
Original comment by yaohua2...@gmail.com
on 14 May 2010 at 2:24
Just committed this patch. Thanks! -joe
Original comment by joe.gregorio@gmail.com
on 14 May 2010 at 3:16
I still get the same error with the latest code in mercurial repository.
Original comment by yaohua2...@gmail.com
on 4 Jun 2010 at 2:25
On Python 2.5 on Debian GNU/Linux the socket error does not have an errno
attribute. Something like the following is required to make this work on 2.5:
if getattr(e, 'errno', e.args[o]) == errno.ECONNREFUSED
Original comment by ugge...@gmail.com
on 4 Jul 2010 at 10:55
@joe.gregorio: could you either re-open this bug (python 2.5 breakage, see
comment 17) or state if you'd prefer a separate bug for that.
Original comment by tre...@gmail.com
on 4 Jul 2010 at 10:55
"AttributeError: 'NoneType' object has no attribute 'makefile'" occured in
Python 3.1.2.
my patch is here.
http://code.google.com/r/msmhrt-httplib2/source/detail?r=b389f44f644360d483bb6a1
6dea4c2bcf3db5399
Original comment by msm...@gmail.com
on 10 Oct 2010 at 12:13
Still seems to be broken (Ubuntu 11.04, Python 2.7.1, python-httplib2
0.6.0-4build1):
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib2
>>> h = httplib2.Http()
>>> r,c = h.request("http://127.0.0.1:8080")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1129, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 901, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 871, in _conn_request
response = conn.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1025, in getresponse
response = self.response_class(*args, **kwds)
File "/usr/lib/python2.7/httplib.py", line 346, in __init__
self.fp = sock.makefile('rb', 0)
AttributeError: 'NoneType' object has no attribute 'makefile'
>>>
With python3 (Python 3.2), this seems to partially work, but with an additional
exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 847, in _conn_request
conn.request(method, request_uri, body, headers)
File "/usr/lib/python3.2/http/client.py", line 964, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.2/http/client.py", line 1002, in _send_request
self.endheaders(body)
File "/usr/lib/python3.2/http/client.py", line 960, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.2/http/client.py", line 805, in _send_output
self.send(msg)
File "/usr/lib/python3.2/http/client.py", line 743, in send
self.connect()
File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 709, in connect
self.timeout)
File "/usr/lib/python3.2/socket.py", line 398, in create_connection
raise err
File "/usr/lib/python3.2/socket.py", line 389, in create_connection
sock.connect(sa)
socket.error: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1116, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 887, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 851, in _conn_request
except (socket.error, httplib.HTTPException):
NameError: global name 'httplib' is not defined
>>>
Original comment by horst.sc...@googlemail.com
on 30 Jul 2011 at 9:06
Would anyone care to reopen, please? Or am I supposed to file a new bug report?
Original comment by horst.sc...@googlemail.com
on 4 Aug 2011 at 9:50
Looks like your version is still 0.6.0 (was that build number supposed to have
the patch?). By my observation it is fixed in 0.7.1:
http://pastebin.com/k9YBtvgR
Original comment by estebis...@gmail.com
on 4 Aug 2011 at 1:57
Original issue reported on code.google.com by
yaohua2...@gmail.com
on 24 Aug 2009 at 6:17