Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request psf#867 from mattswe/patch-1
Handle encoding of `None` when decoding unicode
  • Loading branch information
Kenneth Reitz committed Oct 1, 2012
2 parents 1cb31f2 + 38aced9 commit af61205
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion requests/models.py
Expand Up @@ -828,10 +828,12 @@ def text(self):
# 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')

Expand Down

0 comments on commit af61205

Please sign in to comment.