From 871a3e40f306f1bff056a86edcd644a82ab29c67 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Wed, 15 Oct 2014 18:56:58 +0100 Subject: Fix KeyError raised from client Connection Some client.Connection methods will raise a KeyError if a response_dict argument is passed and an error occurs during authentication or making the request. The fix is straightforward: add a test for existence of a response_dict before attempting to get it from kwargs. The bulk of this patch is adding unit tests for the response_dict feature. Closes-Bug: 1381304 Change-Id: Ic7e1b3dfae33909533931c52ac97355867a08a07 --- swiftclient/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'swiftclient/client.py') diff --git a/swiftclient/client.py b/swiftclient/client.py index def40bf..8372e63 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -1215,7 +1215,7 @@ class Connection(object): ssl_compression=self.ssl_compression) def _add_response_dict(self, target_dict, kwargs): - if target_dict is not None: + if target_dict is not None and 'response_dict' in kwargs: response_dict = kwargs['response_dict'] if 'response_dicts' in target_dict: target_dict['response_dicts'].append(response_dict) -- cgit v1.2.1