From f5a2b75924805f10f8c42945ad96f9e7d9a3f33e Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 21 Jan 2012 01:28:26 -0500 Subject: [PATCH] only try to decode if self.encoding is set --- requests/models.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 -- 2.7.4