From: Dirkjan Ochtman Date: Wed, 24 Feb 2010 04:49:00 +0000 (+0000) Subject: Issue #7427: improve the representation of httplib.BadStatusLine exceptions. X-Git-Tag: v2.7a4~116 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebc73dce57b1c616b966ba05fe68db5a1c646d52;p=python Issue #7427: improve the representation of httplib.BadStatusLine exceptions. --- diff --git a/Lib/httplib.py b/Lib/httplib.py index c5e600c709..43c879790a 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -1236,6 +1236,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 c0c12e7122..107b904ebc 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -91,6 +91,10 @@ class BasicTest(TestCase): resp = httplib.HTTPResponse(sock) 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): # if we have a lenght, the system knows when to close itself # same behaviour than when we read the whole thing with read() diff --git a/Misc/NEWS b/Misc/NEWS index ee77d5dd13..715a346d71 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -60,6 +60,8 @@ Library - Issue #1537721: Add a writeheader() method to csv.DictWriter. +- Issue #7427: improve the representation of httplib.BadStatusLine exceptions. + Extension Modules -----------------