From 11dbfd41957b3602d3adcbe24108b508c4a71356 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 21 Mar 2010 22:50:04 +0000 Subject: Merged revisions 78417 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78417 | dirkjan.ochtman | 2010-02-23 22:49:00 -0600 (Tue, 23 Feb 2010) | 1 line Issue #7427: improve the representation of httplib.BadStatusLine exceptions. ........ --- Lib/http/client.py | 2 ++ Lib/test/test_httplib.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Lib/http/client.py b/Lib/http/client.py index d35f245..b9246fd 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -1121,6 +1121,8 @@ class ResponseNotReady(ImproperConnectionState): class BadStatusLine(HTTPException): def __init__(self, line): + if not line: + line = repr(line) self.args = line, self.line = line diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 705ceec..84e1f80 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -106,6 +106,10 @@ class BasicTest(TestCase): resp = client.HTTPResponse(sock) self.assertRaises(client.BadStatusLine, resp.begin) + def test_bad_status_repr(self): + exc = client.BadStatusLine('') + self.assertEquals(repr(exc), '''BadStatusLine("\'\'",)''') + def test_partial_reads(self): # if we have a lenght, the system knows when to close itself # same behaviour than when we read the whole thing with read() -- cgit v0.12