Rev 5439: (spiv) Fix traceback with python 2.7's xmlrpclib. (Toshio Kuratomi) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Sep 21 11:48:25 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5439 [merge]
revision-id: pqm at pqm.ubuntu.com-20100921104823-0jks3g5o1bahesyq
parent: pqm at pqm.ubuntu.com-20100921093244-q0290ai8j4s3lo1v
parent: toshio at fedoraproject.org-20100915024219-n4oxd40acvdksanc
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2010-09-21 11:48:23 +0100
message:
  (spiv) Fix traceback with python 2.7's xmlrpclib. (Toshio Kuratomi)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
=== modified file 'NEWS'
--- a/NEWS	2010-09-21 09:32:44 +0000
+++ b/NEWS	2010-09-21 10:48:23 +0000
@@ -220,6 +220,9 @@
 Bug Fixes
 *********
 
+* Fix traceback with python-2.7's xmlrpclib
+  (Toshio Kuratomi, #612096)
+
 * Allow using both --using and --diff-options. 
   (Matthäus G. Chajdas, #234708)
 

=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
--- a/bzrlib/transport/http/_urllib2_wrappers.py	2010-05-08 05:56:28 +0000
+++ b/bzrlib/transport/http/_urllib2_wrappers.py	2010-09-15 02:42:19 +0000
@@ -75,6 +75,26 @@
     )
 
 
+class addinfourl(urllib2.addinfourl):
+    '''Replacement addinfourl class compatible with python-2.7's xmlrpclib
+
+    In python-2.7, xmlrpclib expects that the response object that it receives
+    has a getheader method.  httplib.HTTPResponse provides this but
+    urllib2.addinfourl does not.  Add the necessary functions here, ported to
+    use the internal data structures of addinfourl.
+    '''
+
+    def getheader(self, name, default=None):
+        if self.headers is None:
+            raise httplib.ResponseNotReady()
+        return self.headers.getheader(name, default)
+
+    def getheaders(self):
+        if self.headers is None:
+            raise httplib.ResponseNotReady()
+        return self.headers.items()
+
+
 class _ReportingFileSocket(object):
 
     def __init__(self, filesock, report_activity=None):
@@ -656,7 +676,7 @@
             r = response
             r.recv = r.read
             fp = socket._fileobject(r, bufsize=65536)
-            resp = urllib2.addinfourl(fp, r.msg, req.get_full_url())
+            resp = addinfourl(fp, r.msg, req.get_full_url())
             resp.code = r.status
             resp.msg = r.reason
             resp.version = r.version




More information about the bazaar-commits mailing list