Permalink
Browse files

Handle encoding of `None` when decoding unicode

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...
1 parent 5ce2568 commit b1610df282c67cd87781be166549643e647704ee @sweenzor sweenzor committed Sep 25, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 requests/models.py
View
@@ -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

0 comments on commit b1610df

Please sign in to comment.