[PATCH 6/8] xmlrpc: remove a redundant try/except block
Andrew Donnellan
andrew.donnellan at au1.ibm.com
Mon Sep 5 16:08:41 AEST 2016
On 03/09/16 17:07, Daniel Axtens wrote:
> The try block just raises the exception it catches, so just get rid of
> it.
>
> Signed-off-by: Daniel Axtens <dja at axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
> ---
> patchwork/views/xmlrpc.py | 30 +++++++++++++-----------------
> 1 file changed, 13 insertions(+), 17 deletions(-)
>
> diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py
> index c5e7b9078f15..65471e7f9e84 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()
>
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com IBM Australia Limited
More information about the Patchwork
mailing list