From: Ben Pfaff Date: Tue, 23 Aug 2011 00:12:59 +0000 (-0700) Subject: ovs.db.idl: Improve error reporting for bad s. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c0f62718ff9f83613c7f87805ee40495f642583;p=openvswitch 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 --- 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)