diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2012-09-27 18:29:45 +0900 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-09-27 09:11:49 -0700 |
commit | 3b4c362f4078549d9a3bf18a2393e12e4b3ff9f7 (patch) | |
tree | 0173a25ff4914b65658634bcf400e0de3aee7f69 /python | |
parent | f89b7ce502441c9b71ac469846049ecacabcd888 (diff) |
python/ovs/db/idl: getattr(Row) raises TypeError, not AttributeError.
In some cases getattr(Row instance, attrname) doesn't raise AttributeError,
but TypeError
> File "python/ovs/db/idl.py", line 554, in __getattr__
> datum = self._data[column_name]
> TypeError: 'NoneType' object has no attribute '__getitem__'
So getattr(Row instance, attrname, default value) doesn't work.
This occurs when row._changes doesn't include attrname and row._data is None.
So teach Row.__getattr__ _data=None case.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'python')
-rw-r--r-- | python/ovs/db/idl.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py index 3a8dec28..9e9bf0f5 100644 --- a/python/ovs/db/idl.py +++ b/python/ovs/db/idl.py @@ -548,6 +548,9 @@ class Row(object): datum = self._changes.get(column_name) if datum is None: + if self._data is None: + raise AttributeError("%s instance has no attribute '%s'" % + (self.__class__.__name__, column_name)) datum = self._data[column_name] return datum.to_python(_uuid_to_row) |