App: simplify the logic in PropertyLinkList::getPyValue
This commit is contained in:
@@ -715,15 +715,18 @@ PyObject *PropertyLinkList::getPyObject(void)
|
||||
return Py::new_reference_to(sequence);
|
||||
}
|
||||
|
||||
DocumentObject *PropertyLinkList::getPyValue(PyObject *item) const {
|
||||
DocumentObject *PropertyLinkList::getPyValue(PyObject *item) const
|
||||
{
|
||||
if (item == Py_None) {
|
||||
return nullptr;
|
||||
} else if (!PyObject_TypeCheck(item, &(DocumentObjectPy::Type))) {
|
||||
std::string error = std::string("type must be 'DocumentObject', list of 'DocumentObject', or NoneType, not ");
|
||||
error += item->ob_type->tp_name;
|
||||
throw Base::TypeError(error);
|
||||
}
|
||||
return static_cast<DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
else if (PyObject_TypeCheck(item, &(DocumentObjectPy::Type))) {
|
||||
return static_cast<DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
}
|
||||
|
||||
std::string error = std::string("type must be 'DocumentObject', list of 'DocumentObject', or NoneType, not ");
|
||||
error += item->ob_type->tp_name;
|
||||
throw Base::TypeError(error);
|
||||
}
|
||||
|
||||
void PropertyLinkList::Save(Base::Writer &writer) const
|
||||
|
||||
Reference in New Issue
Block a user