From: Daniel Axtens Date: Sat, 3 Sep 2016 07:07:18 +0000 (+1000) Subject: xmlrpc: remove a redundant try/except block X-Git-Tag: v2.0.0-rc1~256 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b23f30d81737ffa77cce3d9684a9f337a8937f22;p=thirdparty%2Fpatchwork.git xmlrpc: remove a redundant try/except block The try block just raises the exception it catches, so just get rid of it. Signed-off-by: Daniel Axtens Reviewed-by: Stephen Finucane --- diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py index c5e7b907..65471e7f 100644 --- a/patchwork/views/xmlrpc.py +++ b/patchwork/views/xmlrpc.py @@ -747,30 +747,26 @@ def patch_set(user, patch_id, params): patch Patch.DoesNotExist: The patch did not exist. """ - try: - ok_params = ['state', 'commit_ref', 'archived'] - - patch = Patch.objects.get(id=patch_id) + ok_params = ['state', 'commit_ref', 'archived'] - if not patch.is_editable(user): - raise Exception('No permissions to edit this patch') + patch = Patch.objects.get(id=patch_id) - for (k, v) in params.items(): - if k not in ok_params: - continue + if not patch.is_editable(user): + raise Exception('No permissions to edit this patch') - if k == 'state': - patch.state = State.objects.get(id=v) + for (k, v) in params.items(): + if k not in ok_params: + continue - else: - setattr(patch, k, v) + if k == 'state': + patch.state = State.objects.get(id=v) - patch.save() + else: + setattr(patch, k, v) - return True + patch.save() - except Patch.DoesNotExist: - raise + return True @xmlrpc_method()