From: Kenneth Reitz Date: Sat, 21 Jan 2012 06:28:26 +0000 (-0500) Subject: only try to decode if self.encoding is set X-Git-Tag: v0.10.0~15^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5a2b75924805f10f8c42945ad96f9e7d9a3f33e;p=services%2Fpython-requests.git only try to decode if self.encoding is set --- diff --git a/requests/models.py b/requests/models.py index 5da4d7e..c116e36 100644 --- a/requests/models.py +++ b/requests/models.py @@ -711,19 +711,19 @@ class Response(object): """Content of the response, in unicode.""" # Try charset from content-type - content = u'' - try: - content = unicode(self.content, self.encoding) - except UnicodeError: - pass + if self.encoding: + try: + content = unicode(self.content, self.encoding) + except UnicodeError: + pass - # Try to fall back: - try: - content = unicode(content, self.encoding, errors='replace') - except TypeError: - pass + # Try to fall back: + try: + content = unicode(content, self.encoding, errors='replace') + except TypeError: + pass return content