From: Matt Sweeney Date: Tue, 25 Sep 2012 22:35:30 +0000 (-0700) Subject: Handle encoding of `None` when decoding unicode X-Git-Tag: v0.14.2~8^2~1^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2bb49ff386deab4e67e199450085720c1521411a;p=services%2Fpython-requests.git Handle encoding of `None` when decoding unicode If encoding is None, decoding will throw the following TypeError: TypeError: unicode() argument 2 must be string, not None If this is the case, attempt to run without any set encoding --- diff --git a/requests/models.py b/requests/models.py index f33c3c3..305e615 100644 --- a/requests/models.py +++ b/requests/models.py @@ -834,6 +834,11 @@ class Response(object): # # So we try blindly encoding. content = str(self.content, errors='replace') + except TypeError: + # A TypeError can be raised if encoding is None + # + # So we try blindly encoding. + content = str(self.content, errors='replace') return content