On Sat, Apr 30, 2022 at 3:10 PM Terry Wilson <twil...@redhat.com> wrote:
>
> 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: 4e3966e64 (python: Politely handle misuse of table.condition.)
> Signed-off-by: Terry Wilson <twil...@redhat.com>
> ---
>  python/ovs/db/idl.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
> index c98985773..ca61c5f73 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:

Part of me thinks that we could just return atom here to return the
UUID if the table wasn't registered, but I went with trying to restore
the previous behavior.

> +                raise AttributeError(
> +                    f"Table {base.ref_table.name} is not registered") from e
> +            return table.rows.get(atom)
>          else:
>              return atom
>
> --
> 2.35.1
>

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to