summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hammond <chipx86@chipx86.com>2010-02-24 23:12:46 -0800
committerChristian Hammond <chipx86@chipx86.com>2010-02-24 23:12:46 -0800
commit84366dbc714224eac0e939eac9c7e4eaf1d157ae (patch)
treee0c7f043b7fcd481a7317fe7b7366895d08ed690
parentdbfbd077cefbf45bc68491efc1218b9f04d812bc (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-xrbtools/postreview.py7
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):