[PATCH 2/8] xmlrpc: Change filter(...)[0] to get(...)
Stephen Finucane
stephenfinucane at hotmail.com
Sun Sep 4 06:17:10 AEST 2016
On 03 Sep 17:07, Daniel Axtens wrote:
> filter() returns a list or [], and get() returns an object or raises an
> exception.
>
> Currently, we use filter()[0] inside a try/except model.DoesNotExist
> block. This doesn't work: if filter returns [] we'll get an exception
> about list indices, not a DoesNotExist exception.
>
> Switch these over to get(), allowing them to use the existing exception
> flow.
>
> Signed-off-by: Daniel Axtens <dja at axtens.net>
Damn. Good catch.
Reviewed-by: Stephen Finucane <stephenfinucane at hotmail.com>
More information about the Patchwork
mailing list