summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorTerry Wilson <twilson@redhat.com>2022-05-02 13:31:14 +0000
committerIlya Maximets <i.maximets@ovn.org>2022-05-02 19:17:53 +0200
commit7d355544256a9a889a876250d357423f0b69a40d (patch)
treec9ac384275fce330b1c7741325070fdf134bc2ae /python
parent218dad97da1f10a455106ecdf3e0c2794e2ef61f (diff)
downloadopenvswitch-7d355544256a9a889a876250d357423f0b69a40d.tar.gz
python: idl: Raise AttributeError from uuid_to_row.
Prior to 4e3966e64, when calling _uuid_to_row, it would raise an AttributeError when trying to access base.ref_table.rows if the referenced table was not registered. When called from Row.__getattr__(), this would appropriately raise an AttributeError. After 4e3966e64, a KeyError would be raised, which is not expected from a getattr() or hasattr() call, which could break existing code. Fixes: 4e3966e64bed ("python: Politely handle misuse of table.condition.") Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'python')
-rw-r--r--python/ovs/db/idl.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index c98985773..b87099ff5 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -1299,7 +1299,12 @@ class Row(object):
def _uuid_to_row(self, atom, base):
if base.ref_table:
- return self._idl.tables[base.ref_table.name].rows.get(atom)
+ try:
+ table = self._idl.tables[base.ref_table.name]
+ except KeyError as e:
+ msg = "Table {} is not registered".format(base.ref_table.name)
+ raise AttributeError(msg) from e
+ return table.rows.get(atom)
else:
return atom