2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-01 23:05:29 +00:00

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: 4e3966e64b ("python: Politely handle misuse of table.condition.")
Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Terry Wilson
2022-05-02 13:31:14 +00:00
committed by Ilya Maximets
parent 218dad97da
commit 7d35554425

View File

@@ -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