From 513bf4c48c8f04014c9f32c330378ddc93fcbb1c Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Thu, 20 Oct 2016 16:48:10 +0900 Subject: [PATCH] ovs/vsctl: Avoid applying next() to non-iterator object In Python 2, the builtin function next() can not be applied to non-iterator object. This patch fixes to use the list comprehensions and avoid applying next() to a list type object. Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/lib/ovs/vsctl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ryu/lib/ovs/vsctl.py b/ryu/lib/ovs/vsctl.py index f1454985..66c2d628 100644 --- a/ryu/lib/ovs/vsctl.py +++ b/ryu/lib/ovs/vsctl.py @@ -126,8 +126,8 @@ def datum_from_string(type_, value_string, symtab=None): def ifind(pred, seq): try: - return next(filter(pred, seq)) - except StopIteration: + return [i for i in seq if pred(i)][0] + except IndexError: return None