From c2fab5b4ca2f8dcdc76fabb1851bd268f0d41889 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Tue, 28 Jan 2014 20:24:41 -0600 Subject: [PATCH] Avoid having to fix tests --- requests/exceptions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/requests/exceptions.py b/requests/exceptions.py index 7c291f2b..c8ec089f 100644 --- a/requests/exceptions.py +++ b/requests/exceptions.py @@ -18,9 +18,10 @@ class RequestException(IOError): """ Initialize RequestException with `request` and `response` objects. """ - self.response = kwargs.pop('response', None) + response = kwargs.pop('response', None) + self.response = response self.request = kwargs.pop('request', None) - if self.response and not self.request: + if response and not self.request and hasattr(response, 'request'): self.request = self.response.request super(RequestException, self).__init__(*args, **kwargs)