Merge pull request #867 from mattswe/patch-1

Handle encoding of `None` when decoding unicode
This commit is contained in:
Kenneth Reitz
2012-10-01 09:53:56 -07:00
+3 -1
View File
@@ -828,10 +828,12 @@ class Response(object):
# Decode unicode from given encoding.
try:
content = str(self.content, encoding, errors='replace')
except LookupError:
except (LookupError, TypeError):
# A LookupError is raised if the encoding was not found which could
# indicate a misspelling or similar mistake.
#
# A TypeError can be raised if encoding is None
#
# So we try blindly encoding.
content = str(self.content, errors='replace')