# HG changeset patch # User dfraser # Date 1242039694 0 # Node ID bf3e0c2f6b803aaa8d44678dc6dd3544ab61def7 # Parent 1a4541c87021eb38cfd149edda385662926222c1 Apply patch to allow Python 2.3 compatibility (remy blank) - fixes #163 diff --git a/bitten/slave.py b/bitten/slave.py --- a/bitten/slave.py +++ b/bitten/slave.py @@ -49,9 +49,12 @@ else: return False -class SaneHTTPErrorProcessor(urllib2.HTTPErrorProcessor): +# Python 2.3 doesn't include HTTPErrorProcessor in urllib2. So instead of deriving we just make our own one +class SaneHTTPErrorProcessor(HTTPErrorProcessor): "The HTTPErrorProcessor defined in urllib needs some love." + handler_order = 1000 + def http_response(self, request, response): code, msg, hdrs = response.code, response.msg, response.info() if code >= 300: @@ -59,6 +62,7 @@ 'http', request, response, code, msg, hdrs) return response + https_response = http_response class SaneHTTPRequest(urllib2.Request): @@ -145,7 +149,10 @@ log.debug('Sending %s request to %r', method, url) req = SaneHTTPRequest(method, url, body, headers or {}) try: - return self.opener.open(req) + resp = self.opener.open(req) + if not hasattr(resp, 'code'): + resp.code = 200 + return resp except urllib2.HTTPError, e: if e.code >= 300: log.warning('Server returned error %d: %s', e.code, e.msg) @@ -212,7 +219,7 @@ body = str(xml) log.debug('Sending slave configuration: %s', body) resp = self.request('POST', url, body, { - 'Content-Length': len(body), + 'Content-Length': str(len(body)), 'Content-Type': 'application/x-bitten+xml' })