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;