Skip to content

Commit

Permalink
python: idl: Raise AttributeError from uuid_to_row.
Browse files Browse the repository at this point in the history
Prior to 4e3966e, 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 4e3966e, a KeyError would be raised, which is not expected
from a getattr() or hasattr() call, which could break existing
code.

Fixes: 4e3966e ("python: Politely handle misuse of table.condition.")
Signed-off-by: Terry Wilson <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
otherwiseguy authored and igsilya committed May 2, 2022
1 parent 218dad9 commit 7d35554
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/ovs/db/idl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,12 @@ def __str__(self):

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

Expand Down

0 comments on commit 7d35554

Please sign in to comment.