App: do not return null Shape in PropertyContainerPy

This commit is contained in:
Zheng, Lei
2019-08-27 09:18:34 +08:00
committed by wmayer
parent 04d678571c
commit 0cb599a31c

View File

@@ -482,14 +482,12 @@ PyObject *PropertyContainerPy::getCustomAttributes(const char* attr) const
}
Property *prop = getPropertyContainerPtr()->getPropertyByName(attr);
if (prop) {
PY_TRY {
PyObject* pyobj = prop->getPyObject();
if (!pyobj && PyErr_Occurred()) {
// the Python exception is already set
throw Py::Exception();
}
return pyobj;
}PY_CATCH
PyObject* pyobj = prop->getPyObject();
if (!pyobj && PyErr_Occurred()) {
// the Python exception is already set
throw Py::Exception();
}
return pyobj;
}
else if (Base::streq(attr, "__dict__")) {
// get the properties to the C++ PropertyContainer class
@@ -528,7 +526,12 @@ PyObject *PropertyContainerPy::getCustomAttributes(const char* attr) const
if(_getShape != Py_None) {
Py::Tuple args(1);
args.setItem(0,Py::Object(const_cast<PropertyContainerPy*>(this)));
return PyObject_CallObject(_getShape, args.ptr());
Py::Object res(PyObject_CallObject(_getShape, args.ptr()),true);
if(res.hasAttr("isNull")) {
Py::Callable func(res.getAttr("isNull"));
if(!func.apply().isTrue())
return Py::new_reference_to(res);
}
}
}