From a7676ffe157e86bb6717129d2a1421f5176a1ec5 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 19 Jul 2021 09:12:44 +0200 Subject: [PATCH] fix KeyError when dumping analog/PWM mapping configuration --- tools/odrive/pyfibre/fibre/libfibre.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/odrive/pyfibre/fibre/libfibre.py b/tools/odrive/pyfibre/fibre/libfibre.py index 8b922bef..e1087d82 100644 --- a/tools/odrive/pyfibre/fibre/libfibre.py +++ b/tools/odrive/pyfibre/fibre/libfibre.py @@ -669,7 +669,7 @@ class RemoteObject(object): self.__sealed__ = True def __setattr__(self, key, value): - if self.__sealed__ and not hasattr(self, key): + if self.__sealed__ and not key in dir(self) and not hasattr(self, key): raise AttributeError("Attribute {} not found".format(key)) object.__setattr__(self, key, value) @@ -846,6 +846,17 @@ class LibFibre(): def _on_found_object(self, ctx, obj, intf): py_obj = self._load_py_obj(obj, intf) discovery = self.discovery_processes[ctx] + + # TODO: this is a hack because ObjectPtrCodec is broken + def load(subobj): + for key in dir(subobj): + if not key.startswith('_'): + attr = getattr(subobj.__class__, key) + if isinstance(attr, RemoteAttribute): + load(attr._get_obj(subobj)) + + load(py_obj) + discovery._unannounced.append(py_obj) old_future = discovery._future discovery._future = self.loop.create_future()