[issue8823] urllib2 does not catch httplib.BadStatusLine

2015-11-16 Thread Martin Panter

Martin Panter added the comment:

Issue 13736 also proposes to wrap HTTP client exceptions, although I personally 
don’t really endorse this.

The other option is to fix the documentation: Issue 25633, Issue 22797.

--
resolution: accepted -> duplicate
status: open -> closed
superseder:  -> urllib.request.urlopen leaks exceptions from socket and 
httplib.client

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8823] urllib2 does not catch httplib.BadStatusLine

2015-04-11 Thread Martin Panter

Martin Panter added the comment:

See also Issue 22797, about documenting that non-URLError exceptions may be 
raised.

--
nosy: +vadmium

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8823] urllib2 does not catch httplib.BadStatusLine

2012-07-11 Thread Greg Roodt

Greg Roodt  added the comment:

By the way, the issue can be recreated by running the following:

netcat -l -p  -e "echo HTTP/1.1 1000 OK" &
python -c "import urllib2; urllib2.urlopen('http://localhost:')"

This happens on 2.6, 2.7 and 3 by the looks of it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8823] urllib2 does not catch httplib.BadStatusLine

2012-07-07 Thread Greg Roodt

Greg Roodt  added the comment:

I've made a small change to urllib2 to catch the httplib.BadStatusLine and 
raise as URLError. This exception should rarely happen as it means the server 
is returning invalid responses. Nevertheless, I've added a test and hopefully 
fixed the issue.

Patch is attached. I will check if this needs to be added to newer versions of 
Python.

--
keywords: +patch
nosy: +groodt
Added file: http://bugs.python.org/file26298/bad_status_urlerror.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8823] urllib2 does not catch httplib.BadStatusLine

2010-05-26 Thread Senthil Kumaran

Senthil Kumaran  added the comment:

urllib2 is currently catching the socket.error exceptions and presenting the 
reason as custom URLError exception. To address this issue, the module should 
catch the httplib raised exceptions also and present it.

--
assignee:  -> orsenthil
nosy: +orsenthil
resolution:  -> accepted

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8823] urllib2 does not catch httplib.BadStatusLine

2010-05-26 Thread AdamN

Changes by AdamN :


--
components: +Library (Lib)

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8823] urllib2 does not catch httplib.BadStatusLine

2010-05-26 Thread AdamN

Changes by AdamN :


--
versions: +Python 2.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8823] urllib2 does not catch httplib.BadStatusLine

2010-05-26 Thread AdamN

New submission from AdamN :

When running urllib2 and getting a BadStatus from an http server, this error is 
raised:

  File "/var/www/pinax-env/pline/apps/page/models.py", line 303, in render
content = urllib2.urlopen(self.url,timeout=10).read()
  File "/usr/lib/python2.6/urllib2.py", line 124, in urlopen
return _opener.open(url, data, timeout)
  File "/usr/lib/python2.6/urllib2.py", line 389, in open
response = self._open(req, data)
  File "/usr/lib/python2.6/urllib2.py", line 407, in _open
'_open', req)
  File "/usr/lib/python2.6/urllib2.py", line 367, in _call_chain
result = func(*args)
  File "/usr/lib/python2.6/urllib2.py", line 1146, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.6/urllib2.py", line 1119, in do_open
r = h.getresponse()
  File "/usr/lib/python2.6/httplib.py", line 974, in getresponse
response.begin()
  File "/usr/lib/python2.6/httplib.py", line 391, in begin
version, status, reason = self._read_status()
  File "/usr/lib/python2.6/httplib.py", line 355, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine

Because urllib2 doesn't catch it with this:

lines 1116-1120

try:
h.request(req.get_method(), req.get_selector(), req.data, headers)
r = h.getresponse()
except socket.error, err: # XXX what error?
raise URLError(err)

It is not caught anywhere else and the call blows up unless I make a special 
exception for all httplib exceptions.  The specific url that blew this up is:

http://phoenix.untd.com/oasx/rqst/type=sx/rdb=8203014d74555355533a415a2d2d2d2d2d2d2d2d2d2d011d494a0901/version=3/origin=uol/isp=et_cau

--
messages: 106526
nosy: adamnelson
priority: normal
severity: normal
status: open
title: urllib2 does not catch httplib.BadStatusLine
type: behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com