From 31273bc1c6143e8f76f252d90f6f2281efcde4c8 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Tue, 27 Aug 2019 19:37:18 +0800 Subject: [PATCH] App: more sanity check in PropertyContainerPy --- src/App/PropertyContainerPyImp.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 7960ae8ada..9a62ca54d3 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -526,11 +526,16 @@ PyObject *PropertyContainerPy::getCustomAttributes(const char* attr) const if(_getShape != Py_None) { Py::Tuple args(1); args.setItem(0,Py::Object(const_cast(this))); - 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); + auto res = PyObject_CallObject(_getShape, args.ptr()); + if(!res) + PyErr_Clear(); + else { + Py::Object pyres(res,true); + if(pyres.hasAttr("isNull")) { + Py::Callable func(pyres.getAttr("isNull")); + if(!func.apply().isTrue()) + return Py::new_reference_to(res); + } } } }