diff options
author | alex-dr <alex@datarobot.com> | 2017-03-22 00:41:32 -0400 |
---|---|---|
committer | alex-dr <alex@datarobot.com> | 2017-03-22 00:49:07 -0400 |
commit | e0e740438087971bc976a57cdb8d3044fb3fecd4 (patch) | |
tree | 4680e1b14c1137e7baf8c612bceb9960596e82d0 /docker/errors.py | |
parent | 24f75ea212e2ec08272fb73f4af1dc587132236f (diff) | |
download | docker-py-e0e740438087971bc976a57cdb8d3044fb3fecd4.tar.gz |
Fix APIError status_code property for client/server errors
requests.Response objects evaluate as falsy when the status_code
attribute is in the 400-500 range. Therefore we are assured that
prior to this change, APIError would show `is_server_error() == False`
when generated with a 500-level response and `is_client_error() == False`
when generated with a 400-level response. This is not desirable.
Added some seemingly dry (not DRY) unit tests to ensure nothing silly
slips back in here.
Signed-off-by: alex-dr <alex@datarobot.com>
Diffstat (limited to 'docker/errors.py')
-rw-r--r-- | docker/errors.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/docker/errors.py b/docker/errors.py index d9b197d..03b89c1 100644 --- a/docker/errors.py +++ b/docker/errors.py @@ -59,7 +59,7 @@ class APIError(requests.exceptions.HTTPError, DockerException): @property def status_code(self): - if self.response: + if self.response is not None: return self.response.status_code def is_client_error(self): |