Skip to content

Commit 10438e3

Browse files
committed
check if the value is callable
1 parent 8579a1b commit 10438e3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Controller.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ void moduleAddController(py::module &m) {
284284

285285
// Override __setattr__ to invalidate the method cache when an "on*" attribute is reassigned
286286
f.def("__setattr__", [](py::object self, const std::string& s, py::object value) {
287-
// If the attribute starts with "on", invalidate the cached method
288-
if (s.rfind("on", 0) == 0)
287+
// If the attribute starts with "on" and the new value is callable, invalidate the cached method
288+
if (s.rfind("on", 0) == 0 && PyCallable_Check(value.ptr()))
289289
{
290290
auto* trampoline = dynamic_cast<Controller_Trampoline*>(py::cast<Controller*>(self));
291291
if (trampoline)

0 commit comments

Comments
 (0)