summaryrefslogtreecommitdiff
path: root/swiftclient/exceptions.py
diff options
context:
space:
mode:
authorZack M. Davis <zdavis@swiftstack.com>2015-09-04 15:45:48 -0700
committerZack M. Davis <zdavis@swiftstack.com>2015-09-04 16:24:54 -0700
commit5ae4b42392dfabe366531d2545629947aad76bba (patch)
tree84f62a20ea3f91913e2d10c8df8a4991362cb2e5 /swiftclient/exceptions.py
parent93666bb84abc1edc36fbb3ef5ec194cf774e4826 (diff)
downloadpython-swiftclient-5ae4b42392dfabe366531d2545629947aad76bba.tar.gz
make ClientException.http_status default to None rather than 0
The extant default of zero is a bit counterintuitive; insufficiently-careful programmers using swiftclient in their application might, without carefully reading the source or documentation, write buggy code based on the assumption that the `http_status` attribute is absent or defaults to None if ClientException is raised for reasons other than to indicate an unsuccessful HTTP request. (However improbable this scenario may seem, the present author can sadly attest to it having actually happened at least once.) Just changing the default would break some tests on Python 3, due to the `500 <= err.http_status <= 599` comparison in Connection's _retry method (NoneType and int are not orderable in the Python 3.x series); thus, the case where http_status is None is explicitly folded into a code branch that logs and reraises (whereas previously it would have fallen through to an `else` branch where it would be logged and reraised just the same). While we're here, we might as well make ClientException's __init__ use super() (although admittedly the kinds of multiple-inheritance scenarios in which `super` truly shines seem unlikely to occur here). Change-Id: I8c02bfb4a0ef059e781be5e08fcde13fb1be5b88
Diffstat (limited to 'swiftclient/exceptions.py')
-rw-r--r--swiftclient/exceptions.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/swiftclient/exceptions.py b/swiftclient/exceptions.py
index 9a77672..370a8d0 100644
--- a/swiftclient/exceptions.py
+++ b/swiftclient/exceptions.py
@@ -17,9 +17,9 @@
class ClientException(Exception):
def __init__(self, msg, http_scheme='', http_host='', http_port='',
- http_path='', http_query='', http_status=0, http_reason='',
+ http_path='', http_query='', http_status=None, http_reason='',
http_device='', http_response_content=''):
- Exception.__init__(self, msg)
+ super(ClientException, self).__init__(msg)
self.msg = msg
self.http_scheme = http_scheme
self.http_host = http_host