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 69932742d2
commit 22763c9e4f
6 changed files with 46 additions and 55 deletions

View File

@@ -2065,10 +2065,9 @@ PyObject *PropertyBool::getPyObject()
void PropertyBool::setPyObject(PyObject *value)
{
if (PyBool_Check(value))
setValue(PyObject_IsTrue(value)!=0);
else if(PyLong_Check(value))
setValue(PyLong_AsLong(value)!=0);
if (PyBool_Check(value) || PyLong_Check(value)) {
setValue(PyObject_IsTrue(value) ? true : false);
}
else {
std::string error = std::string("type must be bool, not ");
error += value->ob_type->tp_name;