From 4c0f62718ff9f83613c7f87805ee40495f642583 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 22 Aug 2011 17:12:59 -0700 Subject: [PATCH] ovs.db.idl: Improve error reporting for bad s. Strangely malformed s could hypothetically get confusing error message. Using the Parser class should avoid that. Reported-by: Reid Price --- python/ovs/db/idl.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py index 8ce17515..2a04a98f 100644 --- a/python/ovs/db/idl.py +++ b/python/ovs/db/idl.py @@ -15,6 +15,7 @@ import logging import ovs.jsonrpc +import ovs.db.parser import ovs.db.schema from ovs.db import error import ovs.ovsuuid @@ -206,16 +207,11 @@ class Idl: 'is not an object' % (table_name, uuid_string)) - old = row_update.get("old", None) - new = row_update.get("new", None) + parser = ovs.db.parser.Parser(json, "row-update") + old = parser.get_optional("old", [dict]) + new = parser.get_optional("new", [dict]) + parser.finish() - if old is not None and type(old) != dict: - raise error.Error('"old" is not an object', old) - if new is not None and type(new) != dict: - raise error.Error('"new" is not an object', new) - if (old is not None) + (new is not None) != len(row_update): - raise error.Error(" contains unexpected " - "member", row_update) if not old and not new: raise error.Error(' missing "old" and ' '"new" members', row_update) -- 2.30.2