Rev 4631: Fix some more pycurl related karmic test failures in http://bazaar.launchpad.net/~vila/bzr/integration

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Aug 20 05:01:30 BST 2009


At http://bazaar.launchpad.net/~vila/bzr/integration

------------------------------------------------------------
revno: 4631 [merge]
revision-id: v.ladeuil+lp at free.fr-20090820040116-7v2z73z7guqoeg09
parent: pqm at pqm.ubuntu.com-20090819203126-tcghmd36432ss7o8
parent: v.ladeuil+lp at free.fr-20090819163339-80g9c3lad00wpe0v
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: integration
timestamp: Thu 2009-08-20 06:01:16 +0200
message:
  Fix some more pycurl related karmic test failures
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_http.py      testhttp.py-20051018020158-b2eef6e867c514d9
  bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
  bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
  bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2009-08-19 18:04:49 +0000
+++ b/NEWS	2009-08-20 04:01:16 +0000
@@ -24,13 +24,13 @@
 Bug Fixes
 *********
 
+* Fix a pycurl related test failure on karmic by recognizing an error
+  raised by newer versions of pycurl.
+  (Vincent Ladeuil, #306264)
+
 Improvements
 ************
 
-* A better description of the platform is shown in crash tracebacks, ``bzr
-  --version`` and ``bzr selftest``.
-  (Martin Pool, #409137)
-
 Documentation
 *************
 

=== modified file 'bzrlib/tests/test_http.py'
--- a/bzrlib/tests/test_http.py	2009-06-10 03:56:49 +0000
+++ b/bzrlib/tests/test_http.py	2009-08-19 16:33:39 +0000
@@ -625,14 +625,17 @@
         # for details) make no distinction between a closed
         # socket and badly formatted status line, so we can't
         # just test for ConnectionError, we have to test
-        # InvalidHttpResponse too.
-        self.assertRaises((errors.ConnectionError, errors.InvalidHttpResponse),
+        # InvalidHttpResponse too. And pycurl may raise ConnectionReset
+        # instead of ConnectionError too.
+        self.assertRaises(( errors.ConnectionError, errors.ConnectionReset,
+                            errors.InvalidHttpResponse),
                           t.has, 'foo/bar')
 
     def test_http_get(self):
         server = self.get_readonly_server()
         t = self._transport(server.get_url())
-        self.assertRaises((errors.ConnectionError, errors.InvalidHttpResponse),
+        self.assertRaises((errors.ConnectionError, errors.ConnectionReset,
+                           errors.InvalidHttpResponse),
                           t.get, 'foo/bar')
 
 

=== modified file 'bzrlib/transport/http/__init__.py'
--- a/bzrlib/transport/http/__init__.py	2009-04-27 03:27:46 +0000
+++ b/bzrlib/transport/http/__init__.py	2009-08-19 16:33:39 +0000
@@ -617,7 +617,7 @@
                 raise InvalidHttpResponse(
                     t._remote_path('.bzr/smart'),
                     'Expected 200 response code, got %r' % (code,))
-        except errors.InvalidHttpResponse, e:
+        except (errors.InvalidHttpResponse, errors.ConnectionReset), e:
             raise errors.SmartProtocolError(str(e))
         return body_filelike
 

=== modified file 'bzrlib/transport/http/_pycurl.py'
--- a/bzrlib/transport/http/_pycurl.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/transport/http/_pycurl.py	2009-08-19 16:33:39 +0000
@@ -92,6 +92,7 @@
 CURLE_GOT_NOTHING = _get_pycurl_errcode('E_GOT_NOTHING', 52)
 CURLE_PARTIAL_FILE = _get_pycurl_errcode('E_PARTIAL_FILE', 18)
 CURLE_SEND_ERROR = _get_pycurl_errcode('E_SEND_ERROR', 55)
+CURLE_RECV_ERROR = _get_pycurl_errcode('E_RECV_ERROR', 56)
 CURLE_SSL_CACERT = _get_pycurl_errcode('E_SSL_CACERT', 60)
 CURLE_SSL_CACERT_BADFILE = _get_pycurl_errcode('E_SSL_CACERT_BADFILE', 77)
 
@@ -367,6 +368,9 @@
                         ):
                 raise errors.ConnectionError(
                     'curl connection error (%s)\non %s' % (e[1], url))
+            elif e[0] == CURLE_RECV_ERROR:
+                raise errors.ConnectionReset(
+                    'curl connection error (%s)\non %s' % (e[1], url))
             elif e[0] == CURLE_PARTIAL_FILE:
                 # Pycurl itself has detected a short read.  We do not have all
                 # the information for the ShortReadvError, but that should be

=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
--- a/bzrlib/transport/http/_urllib2_wrappers.py	2009-05-04 15:21:26 +0000
+++ b/bzrlib/transport/http/_urllib2_wrappers.py	2009-08-19 16:33:39 +0000
@@ -46,6 +46,7 @@
 # actual code more or less do that, tests should be written to
 # ensure that.
 
+import errno
 import httplib
 try:
     import kerberos
@@ -541,6 +542,10 @@
                         request.get_full_url(),
                         'Bad status line received',
                         orig_error=exc_val)
+                elif (isinstance(exc_val, socket.error) and len(exc_val.args)
+                      and exc_val.args[0] in (errno.ECONNRESET, 10054)):
+                    raise errors.ConnectionReset(
+                        "Connection lost while sending request.")
                 else:
                     # All other exception are considered connection related.
 



More information about the bazaar-commits mailing list