mirror of
https://github.com/python/cpython.git
synced 2025-11-13 23:46:24 +00:00
Issue #7427: improve the representation of httplib.BadStatusLine exceptions.
This commit is contained in:
parent
e4c74e1ea2
commit
ebc73dce57
3 changed files with 8 additions and 0 deletions
|
|
@ -1236,6 +1236,8 @@ class ResponseNotReady(ImproperConnectionState):
|
||||||
|
|
||||||
class BadStatusLine(HTTPException):
|
class BadStatusLine(HTTPException):
|
||||||
def __init__(self, line):
|
def __init__(self, line):
|
||||||
|
if not line:
|
||||||
|
line = repr(line)
|
||||||
self.args = line,
|
self.args = line,
|
||||||
self.line = line
|
self.line = line
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,10 @@ class BasicTest(TestCase):
|
||||||
resp = httplib.HTTPResponse(sock)
|
resp = httplib.HTTPResponse(sock)
|
||||||
self.assertRaises(httplib.BadStatusLine, resp.begin)
|
self.assertRaises(httplib.BadStatusLine, resp.begin)
|
||||||
|
|
||||||
|
def test_bad_status_repr(self):
|
||||||
|
exc = httplib.BadStatusLine('')
|
||||||
|
self.assertEquals(repr(exc), '''BadStatusLine("\'\'",)''')
|
||||||
|
|
||||||
def test_partial_reads(self):
|
def test_partial_reads(self):
|
||||||
# if we have a lenght, the system knows when to close itself
|
# if we have a lenght, the system knows when to close itself
|
||||||
# same behaviour than when we read the whole thing with read()
|
# same behaviour than when we read the whole thing with read()
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ Library
|
||||||
|
|
||||||
- Issue #1537721: Add a writeheader() method to csv.DictWriter.
|
- Issue #1537721: Add a writeheader() method to csv.DictWriter.
|
||||||
|
|
||||||
|
- Issue #7427: improve the representation of httplib.BadStatusLine exceptions.
|
||||||
|
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue