Make final return statement be useful
authorLars Wirzenius <liw@liw.fi>
Thu, 2 Aug 2012 23:04:26 +0000 (00:04 +0100)
committerLars Wirzenius <liw@liw.fi>
Thu, 2 Aug 2012 23:04:26 +0000 (00:04 +0100)
The final return statement was not useful: it was dead code, and was never
executed, since both the try and except branches of the exception
handling were exiting the method before the final return statement
was reached.

Change the method to follow the structure of the get_data method,
by assigning the return value of urlopen into a variable, which the
final return statement then returns.

jenkinsapi/jenkinsbase.py

index 97b81e3..390e094 100644 (file)
@@ -76,7 +76,7 @@ class JenkinsBase(object):
     def post_data(self, url, content):
         try:
             urlopen = self.get_jenkins_obj().get_opener()
-            return urlopen(url, data=content).read().strip()
+            result = urlopen(url, data=content).read().strip()
         except urllib2.HTTPError, e:
             log.warn("Error post data %s" % url)
             log.exception(e)