[core] try/except around calls to node's lambda

This commit is contained in:
Fabien Castan 2024-06-14 09:21:02 +02:00
parent 54bf61cc5c
commit 8aa76fd1d0

View file

@ -375,7 +375,13 @@ class Attribute(BaseObject):
def defaultValue(self):
if isinstance(self.desc.value, types.FunctionType):
try:
return self.desc.value(self)
except Exception as e:
if not self.node.isCompatibilityNode:
# log message only if we are not in compatibility mode
logging.warning("Failed to evaluate default value (node lambda) for attribute '{}': {}".format(self.name, e))
return None
# Need to force a copy, for the case where the value is a list (avoid reference to the desc value)
return copy.copy(self.desc.value)