From 025cf18714d5514ef89c871a7d7642a04062015b Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 10 Nov 2016 23:57:41 +0100 Subject: [PATCH] do not allow to delete properties in FeaturePythonPyT --- src/App/FeaturePythonPyImp.h | 2 +- src/App/FeaturePythonPyImp.inl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/App/FeaturePythonPyImp.h b/src/App/FeaturePythonPyImp.h index a9ab3a352902..4e72f013df2c 100644 --- a/src/App/FeaturePythonPyImp.h +++ b/src/App/FeaturePythonPyImp.h @@ -24,7 +24,7 @@ #define APP_FEATUREPYTHONPYIMP_H #include -#include +#include namespace App { diff --git a/src/App/FeaturePythonPyImp.inl b/src/App/FeaturePythonPyImp.inl index 3c021d7946dc..a71e47606686 100644 --- a/src/App/FeaturePythonPyImp.inl +++ b/src/App/FeaturePythonPyImp.inl @@ -113,6 +113,12 @@ int FeaturePythonPyT::__setattr(PyObject *obj, char *attr, PyObject template int FeaturePythonPyT::_setattr(char *attr, PyObject *value) { + App::Property *prop = FeaturePyT::getPropertyContainerPtr()->getPropertyByName(attr); + if (prop && !value) { + PyErr_Format(PyExc_AttributeError, "Cannot delete attribute: '%s'", attr); + return -1; + } + int returnValue = FeaturePyT::_setattr(attr, value); if (returnValue == -1) { PyObject* dict_item = value;