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

jeremy.hylton python-3000-checkins at python.org
Wed Aug 8 19:36:34 CEST 2007


Author: jeremy.hylton
Date: Wed Aug  8 19:36:33 2007
New Revision: 56837

Modified:
   python/branches/py3k-struni/Lib/httplib.py
   python/branches/py3k-struni/Lib/urllib2.py
Log:
Fix several failing tests in test_urllib2net.

The HTTPResponse object is being passed to BufferedReader, but it
wasn't designed to be used that way.  These changes extend the hacks
that have already been made in urllib2 to get the tests to pass.

The hacks need to be removed and proper support for use with the io
library.  That's a project for another day.



Modified: python/branches/py3k-struni/Lib/httplib.py
==============================================================================
--- python/branches/py3k-struni/Lib/httplib.py	(original)
+++ python/branches/py3k-struni/Lib/httplib.py	Wed Aug  8 19:36:33 2007
@@ -499,6 +499,20 @@
             self.fp.close()
             self.fp = None
 
+    # These implementations are for the benefit of io.BufferedReader.
+
+    # XXX This class should probably be revised to act more like
+    # the "raw stream" that BufferedReader expects.
+
+    @property
+    def closed(self):
+        return self.isclosed()
+
+    def flush(self):
+        self.fp.flush()
+
+    # End of "raw stream" methods
+
     def isclosed(self):
         # NOTE: it is possible that we will not ever call self.close(). This
         #       case occurs when will_close is TRUE, length is None, and we

Modified: python/branches/py3k-struni/Lib/urllib2.py
==============================================================================
--- python/branches/py3k-struni/Lib/urllib2.py	(original)
+++ python/branches/py3k-struni/Lib/urllib2.py	Wed Aug  8 19:36:33 2007
@@ -1072,6 +1072,10 @@
         # Pick apart the HTTPResponse object to get the addinfourl
         # object initialized properly.
 
+        # XXX Should an HTTPResponse object really be passed to
+        # BufferedReader?  If so, we should change httplib to support
+        # this use directly.
+
         # Add some fake methods to the reader to satisfy BufferedReader.
         r.readable = lambda: True
         r.writable = r.seekable = lambda: False
@@ -1283,7 +1287,6 @@
 
     def connect_ftp(self, user, passwd, host, port, dirs, timeout):
         fw = ftpwrapper(user, passwd, host, port, dirs, timeout)
-##        fw.ftp.set_debuglevel(1)
         return fw
 
 class CacheFTPHandler(FTPHandler):


More information about the Python-3000-checkins mailing list