[ovs-dev] [PATCH 1/2] python: Fix exceptions in IDL

Garg, Sumit sumit at extremenetworks.com
Thu Jun 25 16:07:51 UTC 2015


Committing two fixes that address python exceptions:

1. A bool (has_lock) was being accessed as a function call
   leading to a runtime exception.

2. When 'alert' was turned off on a column, the code was
   erroring out when value for that column was being set
   in a newly inserted row. This is because the row._data
   was None at this time.

An observation related to change #2 - it seems that new
rows are not initialized to defaults and that's why the
NULL error happens.

IMO a newly inserted row should automatically get
intialized to default values. This new behavior can be
implemented as a separate improvement sometime in the
future.

For now, I don't see an issue with adding the additional
check. This new check can continue as-is even after the
new behavior is implemented.

Signed-off-by: Sumit Garg <sumit at extremenetworks.com>
---
 python/ovs/db/idl.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index 45a5a23..f074dbf 100644

--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -875,7 +875,7 @@ class Transaction(object):
             return self._status

         # If we need a lock but don't have it, give up quickly.
-        if self.idl.lock_name and not self.idl.has_lock():
+        if self.idl.lock_name and not self.idl.has_lock:
             self._status = Transaction.NOT_LOCKED
             self.__disassemble()
             return self._status
@@ -1074,7 +1074,7 @@ class Transaction(object):
         # transaction only does writes of existing values, without making
any
         # real changes, we will drop the whole transaction later in
         # ovsdb_idl_txn_commit().)
-        if not column.alert and row._data.get(column.name) == datum:
+        if not column.alert and row._data and row._data.get(column.name)
== datum:
             new_value = row._changes.get(column.name)
             if new_value is None or new_value == datum:
                 return
--
1.7.1

--
Sumit Garg
Extreme Networks
sumit at extremenetworks.com
+1 (919) 595-4971




________________________________

DISCLAIMER:
This e-mail and any attachments to it may contain confidential and proprietary material and is solely for the use of the intended recipient. Any review, use, disclosure, distribution or copying of this transmittal is prohibited except by or on behalf of the intended recipient. If you have received this transmittal in error, please notify the sender and destroy this e-mail and any attachments and all copies, whether electronic or printed.



More information about the dev mailing list