]> granicus.if.org Git - python/commitdiff
Issue #7427: improve the representation of httplib.BadStatusLine exceptions.
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Wed, 24 Feb 2010 04:49:00 +0000 (04:49 +0000)
committerDirkjan Ochtman <dirkjan@ochtman.nl>
Wed, 24 Feb 2010 04:49:00 +0000 (04:49 +0000)
Lib/httplib.py
Lib/test/test_httplib.py
Misc/NEWS

index c5e600c709899aec9100caf05feb21c0dc4aa6bb..43c879790ac05f24bf9d0341e1beca158a86e5e6 100644 (file)
@@ -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
 
index c0c12e712228804a408180eda406a4647b78427c..107b904ebc9106f8043adc5d90ea634b642ab3f6 100644 (file)
@@ -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()
index ee77d5dd13d8bb2b50a9b82f5e7c57791710376c..715a346d7105353dea2e305a74140e1af45b8bdf 100644 (file)
--- 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
 -----------------