App: Check Python types using Base::PyTypeCheck

This commit is contained in:
marioalexis
2022-07-20 01:16:27 -03:00
committed by Uwe
parent 2185b8086d
commit 5cb31ece93
4 changed files with 41 additions and 59 deletions

View File

@@ -845,21 +845,20 @@ PyObject *Application::sGetLinksTo(PyObject * /*self*/, PyObject *args)
return nullptr;
PY_TRY {
Base::PyTypeCheck(&pyobj, &DocumentObjectPy::Type, "Expect the first argument of type App.DocumentObject or None");
DocumentObject *obj = nullptr;
if(pyobj!=Py_None) {
if(!PyObject_TypeCheck(pyobj,&DocumentObjectPy::Type)) {
PyErr_SetString(PyExc_TypeError, "Expect the first argument of type document object");
return nullptr;
}
if (pyobj)
obj = static_cast<DocumentObjectPy*>(pyobj)->getDocumentObjectPtr();
}
auto links = GetApplication().getLinksTo(obj,options,count);
Py::Tuple ret(links.size());
int i=0;
for(auto o : links)
ret.setItem(i++,Py::Object(o->getPyObject(),true));
return Py::new_reference_to(ret);
}PY_CATCH;
}
PY_CATCH;
}
PyObject *Application::sGetDependentObjects(PyObject * /*self*/, PyObject *args)