Skip to content

Commit

Permalink
Fix bug in error handler when response is None
Browse files Browse the repository at this point in the history
Regression introduced in #298.
  • Loading branch information
jamesls committed Jun 6, 2014
1 parent 9aca191 commit c25cf74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions botocore/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def check_for_200_error(response, operation, **kwargs):
# 500 response (with respect to raising exceptions, retries, etc.)
# We're connected *before* all the other retry logic handlers, so as long
# as we switch the error code to 500, we'll retry the error as expected.
if response is None:
# A None response can happen if an exception is raised while
# trying to retrieve the response. See Endpoint._get_response().
return
http_response, parsed = response
if http_response.status_code == 200:
if 'Errors' in parsed:
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ def test_200_response_with_no_error_left_untouched(self):
# We don't touch the status code since there are no errors present.
self.assertEqual(http_response.status_code, 200)

def test_500_response_can_be_none(self):
# A 500 response can raise an exception, which means the response
# object is None. We need to handle this case.
check_for_200_error(None, mock.Mock())


class TestRetryHandlerOrder(BaseSessionTest):
def get_handler_names(self, responses):
Expand Down

0 comments on commit c25cf74

Please sign in to comment.