From 98ac3df71369a6cf9bde35b8e5c8dc5935b028d0 Mon Sep 17 00:00:00 2001 From: Avi Das Date: Sat, 22 Mar 2014 15:42:23 -0500 Subject: [PATCH 1/3] Add __str__ to case insensitive dict. Logging headers for debugging purposes is often necessary, and the currently logging the headers would be using __repr__ which would log the implementation detail of headers, caseinsensitivedict. Adding str lends a more printing and log friendly implementation for case insentitice dict --- requests/structures.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requests/structures.py b/requests/structures.py index a1759137..2addb938 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -108,6 +108,9 @@ class CaseInsensitiveDict(collections.MutableMapping): def __repr__(self): return '%s(%r)' % (self.__class__.__name__, dict(self.items())) + def __str__(self): + return '%s' % (dict(self.items()) + class LookupDict(dict): """Dictionary lookup object.""" From a3fb689942e8a215858ef0619d0ec95e22186c77 Mon Sep 17 00:00:00 2001 From: Avi Das Date: Sat, 22 Mar 2014 16:30:22 -0500 Subject: [PATCH 2/3] Fix parenthesis typo --- requests/structures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests/structures.py b/requests/structures.py index 2addb938..a710e9bb 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -109,7 +109,7 @@ class CaseInsensitiveDict(collections.MutableMapping): return '%s(%r)' % (self.__class__.__name__, dict(self.items())) def __str__(self): - return '%s' % (dict(self.items()) + return '%s' % (dict(self.items())) class LookupDict(dict): From c2e6fe4d5dfbb2bf4e31d70bb7c3f3eda2435beb Mon Sep 17 00:00:00 2001 From: Avi Das Date: Sun, 23 Mar 2014 11:38:37 -0500 Subject: [PATCH 3/3] Shorten str for case insensitive dict --- requests/structures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests/structures.py b/requests/structures.py index a710e9bb..3aa090e8 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -109,7 +109,7 @@ class CaseInsensitiveDict(collections.MutableMapping): return '%s(%r)' % (self.__class__.__name__, dict(self.items())) def __str__(self): - return '%s' % (dict(self.items())) + return str(dict(self.items())) class LookupDict(dict):