From 9f60d9e75b21953674710472248089de1ad23450 Mon Sep 17 00:00:00 2001 From: maiiku Date: Fri, 8 May 2015 11:41:56 +0200 Subject: [PATCH 1/2] Bugfix: use apparent_encoding if encoding is set to None --- intercom/request.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/intercom/request.py b/intercom/request.py index c19ccecf..ad846709 100644 --- a/intercom/request.py +++ b/intercom/request.py @@ -42,10 +42,13 @@ def send_request_to_path(cls, method, url, auth, params=None): @classmethod def parse_body(cls, resp): try: - # use supplied encoding to decode the response content - decoded_body = resp.content.decode(resp.encoding) - if not decoded_body: # return early for empty responses (issue-72) + # return early for empty responses (issue-72) + if not resp.content or not resp.content.strip(): return + # use supplied encoding to decode the response content + decoded_body = resp.content.decode( + resp.encoding or resp.apparent_encoding + ) body = json.loads(decoded_body) if body.get('type') == 'error.list': cls.raise_application_errors_on_failure(body, resp.status_code) From 964444bb69ae1b9a28dbd7fc52e03e3f20208a46 Mon Sep 17 00:00:00 2001 From: Rafael Date: Fri, 24 Apr 2015 10:50:49 +0200 Subject: [PATCH 2/2] Allow values of custom attributes to be None. --- intercom/lib/flat_store.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intercom/lib/flat_store.py b/intercom/lib/flat_store.py index 1c330436..7f426812 100644 --- a/intercom/lib/flat_store.py +++ b/intercom/lib/flat_store.py @@ -12,7 +12,8 @@ def __init__(self, *args, **kwargs): def __setitem__(self, key, value): if not ( isinstance(value, numbers.Real) or - isinstance(value, six.string_types) + isinstance(value, six.string_types) or + value is None ): raise ValueError( "custom data only allows string and real number values")