[issue7427] BadStatusLine is hell to debug

2017-03-12 Thread Martin Panter

Martin Panter added the comment:

This change was only made in 2.7a4, not 2.6

--
versions: +Python 2.7 -Python 2.6

___
Python tracker 

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



[issue7427] BadStatusLine is hell to debug

2014-11-19 Thread Martin Panter

Martin Panter added the comment:

As far as I can tell, the “line” attribute isn’t documented anyway. But Issue 
8450 is opened about improving the exception when the connection is closed.

--
nosy: +vadmium

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



[issue7427] BadStatusLine is hell to debug

2012-09-25 Thread Andrew Swan

Andrew Swan added the comment:

I just got tripped up by this change, I wanted to catch the specific case of an 
http server closing a connection and assumed that the following would work:

try:
  resp = conn.getresponse()
except httplib.BadStatusLine, e:
  if len(e.line) == 0:
# server closed...
  else:
raise

That doesn't work since e.line holds the representation of the empty string 
instead of just holding the empty string.  I think the fragment above would be 
a much better way to write this test, the current alterntative of:
  if e.line == '':
is hopelessly obscure.

Seems like the original fix should have been to add __repr__ to BadStatusLine 
rather than changing its contents.  Can this be revisited?

--
nosy: +aswan

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



[issue7427] BadStatusLine is hell to debug

2009-12-04 Thread Jake McGuire

Jake McGuire j...@youtube.com added the comment:

I think what's happening is that your connection is being closed due to 
inactivity, so the status line that comes back is empty.  Printing 
repr(line) would probably make the emptiness clear, but maybe the httplib 
code should put in a more specific message in this case...

--
nosy: +jakemcguire

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



[issue7427] BadStatusLine is hell to debug

2009-12-03 Thread djc

New submission from djc dirk...@ochtman.nl:

For whatever reason, BadStatusLine tracebacks often don't show the line
passed into them. Given the errr, heavy architecture of httplib, this
makes it pretty bad to debug. It's not clear to me why this is:

Traceback (most recent call last):
  File /home/djc/src/couchdb-python/couchdb/tests/client.py, line 138,
in test_attachment_crud_with_files
doc = self.db['foo']
  File /home/djc/src/couchdb-python/couchdb/client.py, line 293, in
__getitem__
_, _, data = self.resource.get(id)
  File /home/djc/src/couchdb-python/couchdb/http.py, line 333, in get
return self._request('GET', path, headers=headers, **params)
  File /home/djc/src/couchdb-python/couchdb/http.py, line 350, in _request
credentials=self.credentials)
  File /home/djc/src/couchdb-python/couchdb/http.py, line 179, in request
resp = _try_request()
  File /home/djc/src/couchdb-python/couchdb/http.py, line 167, in
_try_request
return conn.getresponse()
  File /usr/lib/python2.6/httplib.py, line 950, in getresponse
  File /usr/lib/python2.6/httplib.py, line 390, in begin
  File /usr/lib/python2.6/httplib.py, line 354, in _read_status
BadStatusLine

However, some interactive testing shows that this should work:

d...@enrai couchdb-python $ python
Python 2.6.2 (r262:71600, Oct  5 2009, 12:18:48)
[GCC 4.3.2] on linux2
Type help, copyright, credits or license for more information.
 class CrapShoot(Exception):
... def __init__(self, a):
... self.args = a,
...
 raise CrapShoot('a')
Traceback (most recent call last):
  File stdin, line 1, in module
__main__.CrapShoot: a
 class ParentExc(Exception):
... pass
...
 class CrapShoot(ParentExc):
... def __init__(self, a):
... self.args = a,
...
 raise CrapShoot('a')
Traceback (most recent call last):
  File stdin, line 1, in module
__main__.CrapShoot: a


Definition of BadStatusLine:

class BadStatusLine(HTTPException):
def __init__(self, line):
self.args = line,
self.line = line

class HTTPException(Exception):
# Subclasses that define an __init__ must call Exception.__init__
# or define self.args.  Otherwise, str() will fail.
pass

The note here seems like a cautionary but insufficient tale...

--
components: Library (Lib)
messages: 95934
nosy: djc
severity: normal
status: open
title: BadStatusLine is hell to debug
versions: Python 2.6

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



[issue7427] BadStatusLine is hell to debug

2009-12-03 Thread djc

djc dirk...@ochtman.nl added the comment:

Also, it might be useful here if it showed repr(line) instead of just
line, but that'd just be icing on the cake.

--

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