Ensure that .raw() is present after unpickling.
authorCory Benfield <lukasaoz@gmail.com>
Wed, 12 Mar 2014 18:34:43 +0000 (18:34 +0000)
committerCory Benfield <lukasaoz@gmail.com>
Wed, 12 Mar 2014 18:34:43 +0000 (18:34 +0000)
Some people will assume that .raw() is present, and they shouldn't get
AttributeErrors when they make that assumption on a pickled Response.
However, @kennethreitz has asked that we not be too dependent on
urllib3. For that reason, set to None.

requests/models.py

index cd232e68094869a68bde81c729cf2e42fb9e6039..e2fa09f8cefa31960d3a6c48844adecbb2423146 100644 (file)
@@ -575,6 +575,7 @@ class Response(object):
 
         # pickled objects do not have .raw
         setattr(self, '_content_consumed', True)
+        setattr(self, 'raw', None)
 
     def __repr__(self):
         return '<Response [%s]>' % (self.status_code)