Rev 5117: (vila) Fix https compatibility with python2.7 (Vincent Ladeuil) in file:///home/pqm/archives/thelove/bzr/2.2/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Dec 24 19:02:18 GMT 2010


At file:///home/pqm/archives/thelove/bzr/2.2/

------------------------------------------------------------
revno: 5117 [merge]
revision-id: pqm at pqm.ubuntu.com-20101224190215-x3132uugt3ovn2up
parent: pqm at pqm.ubuntu.com-20101216172529-yqw26u9ufho22nes
parent: v.ladeuil+lp at free.fr-20101224173625-o26yjen6dy51i844
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Fri 2010-12-24 19:02:15 +0000
message:
  (vila) Fix https compatibility with python2.7 (Vincent Ladeuil)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
=== modified file 'NEWS'
--- a/NEWS	2010-12-16 16:03:26 +0000
+++ b/NEWS	2010-12-24 16:10:07 +0000
@@ -32,6 +32,9 @@
   because this can cause knock-on errors at awkward times.
   (Andrew Bennetts, #687653)
 
+* ``https`` access works again with recent versions of python2.7.
+  (Vincent Ladeuil, #693880)
+
 * RevisionTree.is_executable no longer returns None for directories and
   symlinks.  Instead, it returns False, like other Trees and methods.
   (Aaron Bentley, #681885)

=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
--- a/bzrlib/transport/http/_urllib2_wrappers.py	2010-10-08 10:09:37 +0000
+++ b/bzrlib/transport/http/_urllib2_wrappers.py	2010-12-24 17:36:25 +0000
@@ -90,15 +90,19 @@
         self.report_activity(len(s), 'read')
         return s
 
-    def readline(self):
-        # This should be readline(self, size=-1), but httplib in python 2.4 and
-        #  2.5 defines a SSLFile wrapper whose readline method lacks the size
-        #  parameter.  So until we drop support for 2.4 and 2.5 and since we
-        #  don't *need* the size parameter we'll stay with readline(self)
-        #  --  vila 20090209
-        s = self.filesock.readline()
-        self.report_activity(len(s), 'read')
-        return s
+    # httplib in python 2.4 and 2.5 defines a SSLFile wrapper whose readline
+    # method lacks the size parameter. python2.6 provides a proper ssl socket
+    # and added it. python2.7 uses it, forcing us to provide it.
+    if sys.version_info < (2, 6):
+        def readline(self):
+            s = self.filesock.readline()
+            self.report_activity(len(s), 'read')
+            return s
+    else:
+        def readline(self, size=-1):
+            s = self.filesock.readline(size)
+            self.report_activity(len(s), 'read')
+            return s
 
     def __getattr__(self, name):
         return getattr(self.filesock, name)




More information about the bazaar-commits mailing list