Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
fix wrong reraise value, fix #578
Browse files Browse the repository at this point in the history
  • Loading branch information
binux committed Nov 21, 2016
1 parent 4b89fec commit d220598
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyspider/libs/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def raise_for_status(self, allow_redirects=True):
return
elif self.error:
if self.traceback:
six.reraise(Exception, self.error, Traceback.from_string(self.traceback).as_traceback())
six.reraise(Exception, Exception(self.error), Traceback.from_string(self.traceback).as_traceback())
http_error = HTTPError(self.error)
elif (self.status_code >= 300) and (self.status_code < 400) and not allow_redirects:
http_error = HTTPError('%s Redirection' % (self.status_code))
Expand Down
5 changes: 5 additions & 0 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ def test_60_not_ok(self):
response = self.get('/status/600')
self.assertFalse(response.ok)
self.assertFalse(response)

def test_70_reraise_exception(self):
response = self.get('file://abc')
with self.assertRaisesRegexp(Exception, 'HTTP 599'):
response.raise_for_status()

0 comments on commit d220598

Please sign in to comment.