diff options
author | Christian Hammond <chipx86@chipx86.com> | 2010-02-24 23:12:46 -0800 |
---|---|---|
committer | Christian Hammond <chipx86@chipx86.com> | 2010-02-24 23:12:46 -0800 |
commit | 84366dbc714224eac0e939eac9c7e4eaf1d157ae (patch) | |
tree | e0c7f043b7fcd481a7317fe7b7366895d08ed690 | |
parent | dbfbd077cefbf45bc68491efc1218b9f04d812bc (diff) |
Protect against an uninitialized variable.
The new flexible HTTP error handling code had an uninitialized variable. This
checks for it and makes sure not to break.
Patch by Laurent Nicolas.
Reviewed at http://reviews.reviewboard.org/r/1427/
-rwxr-xr-x | rbtools/postreview.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/rbtools/postreview.py b/rbtools/postreview.py index 99dcad3..d5fa0e0 100755 --- a/rbtools/postreview.py +++ b/rbtools/postreview.py @@ -125,7 +125,7 @@ class APIError(Exception): if self.error_code: code_str += ', API Error %d' % self.error_code - if 'err' in self.rsp: + if self.rsp and 'err' in self.rsp: return '%s (%s)' % (self.rsp['err']['msg'], code_str) else: return code_str @@ -417,6 +417,8 @@ class ReviewBoardServer(object): rsp = self.api_post('api/json/reviewrequests/new/', data) except APIError, e: if e.error_code == 204: # Change number in use + rsp = e.rsp + if options.diff_only: # In this case, fall through and return to tempt_fate. debug("Review request already exists.") @@ -427,8 +429,9 @@ class ReviewBoardServer(object): rsp['review_request']['id']) else: raise e + else: + debug("Review request created") - debug("Review request created") return rsp['review_request'] def set_review_request_field(self, review_request, field, value): |