From d4eb49c63c500f58f09ff3f3259ac33ed7b051c4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 17 Mar 2020 14:03:14 +0100 Subject: [PATCH] App: [skip ci] extend Python wrapper of hasExtension() to have full control over calling the C++ function --- src/App/ExtensionContainerPyImp.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/App/ExtensionContainerPyImp.cpp b/src/App/ExtensionContainerPyImp.cpp index 4c3dfe8581..75a6f4d148 100644 --- a/src/App/ExtensionContainerPyImp.cpp +++ b/src/App/ExtensionContainerPyImp.cpp @@ -174,19 +174,21 @@ int ExtensionContainerPy::setCustomAttributes(const char* /*attr*/, PyObject * / PyObject* ExtensionContainerPy::hasExtension(PyObject *args) { char *type; - if (!PyArg_ParseTuple(args, "s", &type)) + PyObject *deriv = Py_True; + if (!PyArg_ParseTuple(args, "s|O", &type, &deriv)) return NULL; // NULL triggers exception //get the extension type asked for + bool derived = PyObject_IsTrue(deriv); Base::Type extension = Base::Type::fromName(type); - if(extension.isBad() || !extension.isDerivedFrom(App::Extension::getExtensionClassTypeId())) { + if (extension.isBad() || !extension.isDerivedFrom(App::Extension::getExtensionClassTypeId())) { std::stringstream str; str << "No extension found of type '" << type << "'" << std::ends; throw Py::Exception(Base::BaseExceptionFreeCADError,str.str()); } bool val = false; - if (getExtensionContainerPtr()->hasExtension(extension)) { + if (getExtensionContainerPtr()->hasExtension(extension, derived)) { val = true; }