make sure that the passed 'self' pointer to a method of the Python wrapper is never null

This commit is contained in:
wmayer 2017-01-24 12:34:23 +01:00
parent 294b2308d6
commit 09846721f2

View File

@ -460,6 +460,12 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject
PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject *args)
-
{
// make sure that not a null pointer is passed
if (!self) {
PyErr_SetString(PyExc_TypeError, "descriptor '@i.Name@' of '@self.export.Namespace@.@self.export.Twin@' object needs an argument");
return NULL;
}
// test if twin object not allready deleted
if (!static_cast<PyObjectBase*>(self)->isValid()) {
PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");