From b88d8be0d1cc945d7e30259978fa9cf619a5ec11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Casafranca?= Date: Tue, 11 May 2021 01:33:39 +0200 Subject: [PATCH] Fix _setattr__ --- .../Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp index f8dc3021..65908db1 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp @@ -126,16 +126,8 @@ void BindingBase::SetAttr(py::object self, const std::string& s, py::object valu return; } - /// We are falling back to dynamically adding the objet into the object dict. - py::dict t = self.attr("__dict__"); - if(!t.is_none()) - { - t[s.c_str()] = value; - return; - } - - /// Well this should never happen unless there is no __dict__ - throw py::attribute_error("Unable to set attribute '"+s+"', unknow data type"); + // If it's not a data or a link, rely on object implementation of __setattr__ + py::module::import("builtins").attr("object").attr("__setattr__")(self, s, value); } void BindingBase::SetAttr(Base& self, const std::string& s, py::object value)