[Python-checkins] r79258 - in python/branches/py3k: Lib/http/client.py Lib/test/test_httplib.py

benjamin.peterson python-checkins at python.org
Sun Mar 21 23:50:04 CET 2010


Author: benjamin.peterson
Date: Sun Mar 21 23:50:04 2010
New Revision: 79258

Log:
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.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/http/client.py
   python/branches/py3k/Lib/test/test_httplib.py

Modified: python/branches/py3k/Lib/http/client.py
==============================================================================
--- python/branches/py3k/Lib/http/client.py	(original)
+++ python/branches/py3k/Lib/http/client.py	Sun Mar 21 23:50:04 2010
@@ -1121,6 +1121,8 @@
 
 class BadStatusLine(HTTPException):
     def __init__(self, line):
+        if not line:
+            line = repr(line)
         self.args = line,
         self.line = line
 

Modified: python/branches/py3k/Lib/test/test_httplib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_httplib.py	(original)
+++ python/branches/py3k/Lib/test/test_httplib.py	Sun Mar 21 23:50:04 2010
@@ -106,6 +106,10 @@
         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()


More information about the Python-checkins mailing list