App: Use PyObject_IsTrue in combination with conditional ternary operator

This commit is contained in:
marioalexis
2022-05-17 10:51:11 -03:00
committed by Chris Hennes
parent 7798e8f42b
commit 1bc43b8606
6 changed files with 46 additions and 55 deletions

View File

@@ -174,11 +174,11 @@ PyObject* ExtensionContainerPy::hasExtension(PyObject *args) {
char *type;
PyObject *deriv = Py_True;
if (!PyArg_ParseTuple(args, "s|O", &type, &deriv))
if (!PyArg_ParseTuple(args, "s|O!", &type, &PyBool_Type, &deriv))
return nullptr;
//get the extension type asked for
bool derived = PyObject_IsTrue(deriv);
bool derived = PyObject_IsTrue(deriv) ? true : false;
Base::Type extension = Base::Type::fromName(type);
if (extension.isBad() || !extension.isDerivedFrom(App::Extension::getExtensionClassTypeId())) {
std::stringstream str;