[Python-3000-checkins] r56724 - python/branches/py3k-struni/Lib/httplib.py

jeremy.hylton python-3000-checkins at python.org
Sat Aug 4 05:41:20 CEST 2007


Author: jeremy.hylton
Date: Sat Aug  4 05:41:19 2007
New Revision: 56724

Modified:
   python/branches/py3k-struni/Lib/httplib.py
Log:
Make sure LineAndFileWrapper gets bytes() as its first argument.

This change fixes a test in test_urllib.



Modified: python/branches/py3k-struni/Lib/httplib.py
==============================================================================
--- python/branches/py3k-struni/Lib/httplib.py	(original)
+++ python/branches/py3k-struni/Lib/httplib.py	Sat Aug  4 05:41:19 2007
@@ -340,7 +340,7 @@
         self.will_close = _UNKNOWN      # conn will close at end of response
 
     def _read_status(self):
-        # Initialize with Simple-Response defaults
+        # Initialize with Simple-Response defaults.
         line = str(self.fp.readline(), "iso-8859-1")
         if self.debuglevel > 0:
             print("reply:", repr(line))
@@ -363,8 +363,10 @@
                 self.close()
                 raise BadStatusLine(line)
             else:
-                # assume it's a Simple-Response from an 0.9 server
-                self.fp = LineAndFileWrapper(line, self.fp)
+                # Assume it's a Simple-Response from an 0.9 server.
+                # We have to convert the first line back to raw bytes
+                # because self.fp.readline() needs to return bytes.
+                self.fp = LineAndFileWrapper(bytes(line), self.fp)
                 return "HTTP/0.9", 200, ""
 
         # The status code is a three-digit number


More information about the Python-3000-checkins mailing list