]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 78417 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Sun, 21 Mar 2010 22:50:04 +0000 (22:50 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 21 Mar 2010 22:50:04 +0000 (22:50 +0000)
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
Lib/test/test_httplib.py

index d35f245d26c443b3c342e701a8b1d34404ee7e28..b9246fd3045baf291064b783e65b1f59cd6329e8 100644 (file)
@@ -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
 
index 705ceecb3d77ae686cbca9d1f37c5aa0aa7fe1d6..84e1f80fcea754f3548541be593b64317c331e7f 100644 (file)
@@ -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()