Hi,

bzr is broken since we switched to python2.7, due to an api change
in the xmlrpclib library.

The patch below fixes this issue. The patch is stolen from fedora, 
but it's the same in any $randomlinuxdistro...

$ bzr branch lp:egtk
bzr: ERROR: exceptions.AttributeError: addinfourl instance has no attribute 
'getheader'

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 912, 
in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 1112, 
in run_bzr
    ret = run(*run_argv)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 690, 
in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 705, 
in run
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 135, in 
run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 165, in 
_do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/builtins.py", line 1209, 
in run
    from_location)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/bzrdir.py", line 1032, in 
open_tree_or_branch
    bzrdir = klass.open(location)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/bzrdir.py", line 910, in 
open
    t = get_transport(base, possible_transports=possible_transports)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/lazy_import.py", line 
125, in __call__
    return obj(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/transport/__init__.py", 
line 1569, in get_transport
    base = directories.dereference(base)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/directory_service.py", 
line 58, in dereference
    return service().look_up(name, url)
  File 
"/usr/local/lib/python2.7/site-packages/bzrlib/plugins/launchpad/lp_directory.py",
 line 59, in look_up
    return self._resolve(url)
  File 
"/usr/local/lib/python2.7/site-packages/bzrlib/plugins/launchpad/lp_directory.py",
 line 69, in _resolve
    result = resolve.submit(service)
  File 
"/usr/local/lib/python2.7/site-packages/bzrlib/plugins/launchpad/lp_registration.py",
 line 272, in submit
    self._authenticated)
  File 
"/usr/local/lib/python2.7/site-packages/bzrlib/plugins/launchpad/lp_registration.py",
 line 195, in send_request
    result = method(*method_params)
  File "/usr/local/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/local/lib/python2.7/xmlrpclib.py", line 1570, in __request
    verbose=self.__verbose
  File 
"/usr/local/lib/python2.7/site-packages/bzrlib/plugins/launchpad/lp_registration.py",
 line 78, in request
    return self.parse_response(response)
  File "/usr/local/lib/python2.7/xmlrpclib.py", line 1449, in parse_response
    if response.getheader("Content-Encoding", "") == "gzip":
AttributeError: addinfourl instance has no attribute 'getheader'

bzr 2.2.2 on python 2.7.1 
(OpenBSD-5.0-amd64-Intel-R-_Core-TM-2_Duo_CPU_T7250_@_2.00GHz-64bit-ELF)
arguments: ['/usr/local/bin/bzr', 'branch', 'lp:egtk']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: None
plugins:
  bash_completion      
/usr/local/lib/python2.7/site-packages/bzrlib/plugins/bash_completion [2.2.2]
  launchpad            
/usr/local/lib/python2.7/site-packages/bzrlib/plugins/launchpad [2.2.2]
  netrc_credential_store 
/usr/local/lib/python2.7/site-packages/bzrlib/plugins/netrc_credential_store 
[2.2.2]
  news_merge           
/usr/local/lib/python2.7/site-packages/bzrlib/plugins/news_merge [2.2.2]

*** Bazaar has encountered an internal error.  This probably indicates a
    bug in Bazaar.  You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    including this traceback and a description of the problem.



Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/bzr/Makefile,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile
--- Makefile    8 Jun 2011 17:40:08 -0000       1.16
+++ Makefile    3 Aug 2011 11:30:16 -0000
@@ -4,7 +4,7 @@ COMMENT =       distributed version control sy
 
 MODPY_EGG_VERSION = 2.2.2
 DISTNAME =     bzr-${MODPY_EGG_VERSION}
-REVISION =     0
+REVISION =     1
 CATEGORIES =   devel
 
 HOMEPAGE =     http://bazaar-vcs.org/
Index: patches/patch-bzrlib_transport_http__urllib2_wrappers_py
===================================================================
RCS file: patches/patch-bzrlib_transport_http__urllib2_wrappers_py
diff -N patches/patch-bzrlib_transport_http__urllib2_wrappers_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-bzrlib_transport_http__urllib2_wrappers_py    3 Aug 2011 
11:30:16 -0000
@@ -0,0 +1,43 @@
+$OpenBSD$
+
+Unbreak bzr with python2.7 (xmlrpclib API change)
+https://bugs.launchpad.net/bzr/+bug/612096
+
+--- bzrlib/transport/http/_urllib2_wrappers.py.orig    Thu Nov 25 16:59:33 2010
++++ bzrlib/transport/http/_urllib2_wrappers.py Wed Aug  3 13:10:47 2011
+@@ -75,6 +75,26 @@ from bzrlib import (
+     )
+ 
+ 
++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 @@ class AbstractHTTPHandler(urllib2.AbstractHTTPHandler)
+             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

Reply via email to