]> git.ipfire.org Git - thirdparty/patchwork.git/commit
xmlrpc: Change filter(...)[0] to get(...)
authorDaniel Axtens <dja@axtens.net>
Sat, 3 Sep 2016 07:07:14 +0000 (17:07 +1000)
committerStephen Finucane <stephenfinucane@hotmail.com>
Sat, 3 Sep 2016 22:25:30 +0000 (23:25 +0100)
commit69a57e9a3ebd4490e3192565c92218b2b81c7a04
tree35420fa683c68b5ac9cafc74a4e4144e6b417807
parent2c851d42fd8b3f5f8dbe1162af315c0a984cd660
xmlrpc: Change filter(...)[0] to get(...)

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@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
patchwork/views/xmlrpc.py