Skip to content

Commit

Permalink
Handle encoding of None when decoding unicode
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sweenzor committed Sep 25, 2012
1 parent 5ce2568 commit b1610df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions requests/models.py
Expand Up @@ -834,6 +834,11 @@ def text(self):
#
# 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

Expand Down

0 comments on commit b1610df

Please sign in to comment.