python: add set type for ovs.idl.data.Datum.from_python
authorZong Kai LI <zealokii@gmail.com>
Thu, 21 Jul 2016 06:17:28 +0000 (14:17 +0800)
committerRussell Bryant <russell@ovn.org>
Mon, 25 Jul 2016 14:40:44 +0000 (10:40 -0400)
ovs.db.idl.Datum.from_python fails to handle set type value, while set
type is also a common iterable sequence, just like list and tuple.
No reason IDL caller must to turn set type parameters to list or tuple
type. Otherwise, they will fail to insert data, but get no exception.

Reported-at: https://bugs.launchpad.net/networking-ovn/+bug/1605573
Signed-off-by: Zong Kai LI <zealokii@gmail.com>
Acked-by: Richard Theis <rtheis@us.ibm.com>
Tested-by: Richard Theis <rtheis@us.ibm.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
python/ovs/db/data.py

index 747acd5..6d87f89 100644 (file)
@@ -521,7 +521,7 @@ class Datum(object):
                 ka = Atom.from_python(type_.key, row_to_uuid(k))
                 va = Atom.from_python(type_.value, row_to_uuid(v))
                 d[ka] = va
-        elif isinstance(value, (list, tuple)):
+        elif isinstance(value, (list, set, tuple)):
             for k in value:
                 ka = Atom.from_python(type_.key, row_to_uuid(k))
                 d[ka] = None