Rev 2911: Fix #147530, pycurl error code handling in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Oct 16 12:27:52 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2911
revision-id: pqm at pqm.ubuntu.com-20071016112750-1q8brfaq6metpfn8
parent: pqm at pqm.ubuntu.com-20071016024233-6fmmyqoh0cfnsni8
parent: v.ladeuil+lp at free.fr-20071016094918-0j00q2cjs99y0xnz
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-10-16 12:27:50 +0100
message:
Fix #147530, pycurl error code handling
removed:
bzrlib/transport/http/_pycurl_errors.py _pycurl_errors.py-20060714003436-4zste49ltg697ft9-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
------------------------------------------------------------
revno: 2910.1.1
merged: v.ladeuil+lp at free.fr-20071016094918-0j00q2cjs99y0xnz
parent: pqm at pqm.ubuntu.com-20071016024233-6fmmyqoh0cfnsni8
parent: v.ladeuil+lp at free.fr-20071001084216-fvlt6hyk8lo134zh
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: trunk
timestamp: Tue 2007-10-16 11:49:18 +0200
message:
Fix #147530, pycurl error code handling
------------------------------------------------------------
revno: 2872.4.1
merged: v.ladeuil+lp at free.fr-20071001084216-fvlt6hyk8lo134zh
parent: pqm at pqm.ubuntu.com-20070928041435-uls0r9txks111272
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 147530
timestamp: Mon 2007-10-01 10:42:16 +0200
message:
Fix bug #147530 by enabling more robust error code definitions.
* bzrlib/transport/http/_pycurl.py:
(_get_pycurl_errcode): Wraps error code definition ensuring better
backward/forward compatibility with curl.
(PyCurlTransport._curl_perform): Use our new error code symbols.
* bzrlib/transport/http/_pycurl_errors.py:
Deleted. The design couldn't cope with being compatible with
several pycurl versions.
=== removed file 'bzrlib/transport/http/_pycurl_errors.py'
--- a/bzrlib/transport/http/_pycurl_errors.py 2006-10-05 05:37:25 +0000
+++ b/bzrlib/transport/http/_pycurl_errors.py 1970-01-01 00:00:00 +0000
@@ -1,102 +0,0 @@
-# Copyright (C) 2006 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-# Taken from curl/curl.h
-CURLE_OK = 0
-CURLE_UNSUPPORTED_PROTOCOL = 1
-CURLE_FAILED_INIT = 2
-CURLE_URL_MALFORMAT = 3
-CURLE_URL_MALFORMAT_USER = 4 # (NOT USED)
-CURLE_COULDNT_RESOLVE_PROXY = 5
-CURLE_COULDNT_RESOLVE_HOST = 6
-CURLE_COULDNT_CONNECT = 7
-CURLE_FTP_WEIRD_SERVER_REPLY = 8
-CURLE_FTP_ACCESS_DENIED = 9 # a service was denied by the FTP server
- # due to lack of access - when login fails
- # this is not returned.
-CURLE_FTP_USER_PASSWORD_INCORRECT = 10
-CURLE_FTP_WEIRD_PASS_REPLY = 11
-CURLE_FTP_WEIRD_USER_REPLY = 12
-CURLE_FTP_WEIRD_PASV_REPLY = 13
-CURLE_FTP_WEIRD_227_FORMAT = 14
-CURLE_FTP_CANT_GET_HOST = 15
-CURLE_FTP_CANT_RECONNECT = 16
-CURLE_FTP_COULDNT_SET_BINARY = 17
-CURLE_PARTIAL_FILE = 18
-CURLE_FTP_COULDNT_RETR_FILE = 19
-CURLE_FTP_WRITE_ERROR = 20
-CURLE_FTP_QUOTE_ERROR = 21
-CURLE_HTTP_RETURNED_ERROR = 22
-CURLE_WRITE_ERROR = 23
-CURLE_MALFORMAT_USER = 24 # NOT USED
-CURLE_FTP_COULDNT_STOR_FILE = 25 # failed FTP upload
-CURLE_READ_ERROR = 26 # could open/read from file
-CURLE_OUT_OF_MEMORY = 27
-CURLE_OPERATION_TIMEOUTED = 28 # the timeout time was reached
-CURLE_FTP_COULDNT_SET_ASCII = 29 # TYPE A failed
-CURLE_FTP_PORT_FAILED = 30 # FTP PORT operation failed
-CURLE_FTP_COULDNT_USE_REST = 31 # the REST command failed
-CURLE_FTP_COULDNT_GET_SIZE = 32 # the SIZE command failed
-CURLE_HTTP_RANGE_ERROR = 33 # RANGE "command" didn't work
-CURLE_HTTP_POST_ERROR = 34
-CURLE_SSL_CONNECT_ERROR = 35 # wrong when connecting with SSL
-CURLE_BAD_DOWNLOAD_RESUME = 36 # couldn't resume download
-CURLE_FILE_COULDNT_READ_FILE = 37
-CURLE_LDAP_CANNOT_BIND = 38
-CURLE_LDAP_SEARCH_FAILED = 39
-CURLE_LIBRARY_NOT_FOUND = 40
-CURLE_FUNCTION_NOT_FOUND = 41
-CURLE_ABORTED_BY_CALLBACK = 42
-CURLE_BAD_FUNCTION_ARGUMENT = 43
-CURLE_BAD_CALLING_ORDER = 44 # NOT USED
-CURLE_INTERFACE_FAILED = 45 # CURLOPT_INTERFACE failed
-CURLE_BAD_PASSWORD_ENTERED = 46 # NOT USED
-CURLE_TOO_MANY_REDIRECTS = 47 # catch endless re-direct loops
-CURLE_UNKNOWN_TELNET_OPTION = 48 # User specified an unknown option
-CURLE_TELNET_OPTION_SYNTAX = 49 # Malformed telnet option
-CURLE_OBSOLETE = 50 # NOT USED
-CURLE_SSL_PEER_CERTIFICATE = 51 # peer's certificate wasn't ok
-CURLE_GOT_NOTHING = 52 # when this is a specific error
-CURLE_SSL_ENGINE_NOTFOUND = 53 # SSL crypto engine not found
-CURLE_SSL_ENGINE_SETFAILED = 54 # can not set SSL crypto engine as default
-CURLE_SEND_ERROR = 55 # failed sending network data
-CURLE_RECV_ERROR = 56 # failure in receiving network data
-CURLE_SHARE_IN_USE = 57 # share is in use
-CURLE_SSL_CERTPROBLEM = 58 # problem with the local certificate
-CURLE_SSL_CIPHER = 59 # couldn't use specified cipher
-CURLE_SSL_CACERT = 60 # problem with the CA cert (path?)
-CURLE_BAD_CONTENT_ENCODING = 61 # Unrecognized transfer encoding
-CURLE_LDAP_INVALID_URL = 62 # Invalid LDAP URL
-CURLE_FILESIZE_EXCEEDED = 63 # Maximum file size exceeded
-CURLE_FTP_SSL_FAILED = 64 # Requested FTP SSL level failed
-CURLE_SEND_FAIL_REWIND = 65 # Sending the data requires a rewind that failed
-CURLE_SSL_ENGINE_INITFAILED = 66 # failed to initialise ENGINE
-CURLE_LOGIN_DENIED = 67 # user, password or similar was not
- # accepted and we failed to login
-CURLE_TFTP_NOTFOUND = 68 # file not found on server
-CURLE_TFTP_PERM = 69 # permission problem on server
-CURLE_TFTP_DISKFULL = 70 # out of disk space on server
-CURLE_TFTP_ILLEGAL = 71 # Illegal TFTP operation
-CURLE_TFTP_UNKNOWNID = 72 # Unknown transfer ID
-CURLE_TFTP_EXISTS = 73 # File already exists
-CURLE_TFTP_NOSUCHUSER = 74 # No such user
-
-
-# Create the reverse mapping, so we can look things up.
-errorcode = {}
-for name, val in globals().items():
- if name.startswith('CURLE'):
- errorcode[val] = name
=== modified file 'NEWS'
--- a/NEWS 2007-10-15 09:04:41 +0000
+++ b/NEWS 2007-10-16 09:49:18 +0000
@@ -111,6 +111,10 @@
* Fix log against smart server branches that don't support tags.
(James Westby, #140615)
+ * Fix pycurl http implementation by defining error codes from
+ pycurl instead of relying on an old curl definition.
+ (Vincent Ladeuil, #147530)
+
* Fix 'unprintable error' message when displaying BzrCheckError and
some other exceptions on Python 2.5.
(Martin Pool, #144633)
=== modified file 'bzrlib/transport/http/_pycurl.py'
--- a/bzrlib/transport/http/_pycurl.py 2007-08-15 04:56:08 +0000
+++ b/bzrlib/transport/http/_pycurl.py 2007-10-01 08:42:16 +0000
@@ -49,7 +49,6 @@
ca_bundle,
_extract_headers,
HttpTransportBase,
- _pycurl_errors,
response,
)
@@ -75,6 +74,28 @@
raise DependencyNotPresent('pycurl', e)
+
+
+def _get_pycurl_errcode(symbol, default):
+ """
+ Returns the numerical error code for a symbol defined by pycurl.
+
+ Different pycurl implementations define different symbols for error
+ codes. Old versions never define some symbols (wether they can return the
+ corresponding error code or not). The following addresses the problem by
+ defining the symbols we care about. Note: this allows to define symbols
+ for errors that older versions will never return, which is fine.
+ """
+ return pycurl.__dict__.get(symbol, default)
+
+CURLE_SSL_CACERT_BADFILE = _get_pycurl_errcode('E_SSL_CACERT_BADFILE', 77)
+CURLE_COULDNT_CONNECT = _get_pycurl_errcode('E_COULDNT_CONNECT', 7)
+CURLE_COULDNT_RESOLVE_HOST = _get_pycurl_errcode('E_COULDNT_RESOLVE_HOST', 6)
+CURLE_COULDNT_RESOLVE_PROXY = _get_pycurl_errcode('E_COULDNT_RESOLVE_PROXY', 5)
+CURLE_GOT_NOTHING = _get_pycurl_errcode('E_GOT_NOTHING', 52)
+CURLE_PARTIAL_FILE = _get_pycurl_errcode('E_PARTIAL_FILE', 18)
+
+
register_urlparse_netloc_protocol('http+pycurl')
@@ -269,14 +290,15 @@
except pycurl.error, e:
url = curl.getinfo(pycurl.EFFECTIVE_URL)
mutter('got pycurl error: %s, %s, %s, url: %s ',
- e[0], _pycurl_errors.errorcode[e[0]], e, url)
- if e[0] in (_pycurl_errors.CURLE_COULDNT_RESOLVE_HOST,
- _pycurl_errors.CURLE_COULDNT_CONNECT,
- _pycurl_errors.CURLE_GOT_NOTHING,
- _pycurl_errors.CURLE_COULDNT_RESOLVE_PROXY):
+ e[0], e[1], e, url)
+ if e[0] in (CURLE_SSL_CACERT_BADFILE,
+ CURLE_COULDNT_RESOLVE_HOST,
+ CURLE_COULDNT_CONNECT,
+ CURLE_GOT_NOTHING,
+ CURLE_COULDNT_RESOLVE_PROXY,):
raise ConnectionError('curl connection error (%s)\non %s'
% (e[1], url))
- elif e[0] == _pycurl_errors.CURLE_PARTIAL_FILE:
+ 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 enough
More information about the bazaar-commits
mailing list