diff --git a/requests/models.py b/requests/models.py index f33c3c3e..2193c6e5 100644 --- a/requests/models.py +++ b/requests/models.py @@ -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')