FEM: Ensure finite frame values only. Fixes #20933
This commit is contained in:
@@ -172,7 +172,8 @@ PyObject* FemPostPipelinePy::load(PyObject* args)
|
||||
|
||||
std::string error = std::string(
|
||||
"Result and value must be list of ResultObject and number respectively.");
|
||||
throw Base::TypeError(error);
|
||||
PyErr_SetString(PyExc_TypeError, error.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// extract the result objects
|
||||
@@ -186,11 +187,15 @@ PyObject* FemPostPipelinePy::load(PyObject* args)
|
||||
if (!PyObject_TypeCheck(*item, &(DocumentObjectPy::Type))) {
|
||||
std::string error =
|
||||
std::string("type in result list must be 'ResultObject', not ");
|
||||
throw Base::TypeError(error);
|
||||
PyErr_SetString(PyExc_TypeError, error.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
auto obj = static_cast<DocumentObjectPy*>(*item)->getDocumentObjectPtr();
|
||||
if (!obj->isDerivedFrom<FemResultObject>()) {
|
||||
throw Base::TypeError("object is not a result object");
|
||||
std::string error =
|
||||
std::string("type in result list must be 'ResultObject', not ");
|
||||
PyErr_SetString(PyExc_TypeError, error.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
results[i] = static_cast<FemResultObject*>(obj);
|
||||
}
|
||||
@@ -202,12 +207,12 @@ PyObject* FemPostPipelinePy::load(PyObject* args)
|
||||
values.resize(size);
|
||||
|
||||
for (Py::Sequence::size_type i = 0; i < size; i++) {
|
||||
Py::Object item = values_list[i];
|
||||
if (!PyFloat_Check(*item)) {
|
||||
std::string error = std::string("Values must be float");
|
||||
throw Base::TypeError(error);
|
||||
Py::Object value = values_list[i];
|
||||
if (!value.isNumeric()) {
|
||||
PyErr_SetString(PyExc_TypeError, "Values must be numbers");
|
||||
return nullptr;
|
||||
}
|
||||
values[i] = PyFloat_AsDouble(*item);
|
||||
values[i] = Py::Float(value).as_double();
|
||||
}
|
||||
|
||||
// extract the unit
|
||||
@@ -223,7 +228,8 @@ PyObject* FemPostPipelinePy::load(PyObject* args)
|
||||
else {
|
||||
std::string error = std::string(
|
||||
"Multistep load requires 4 arguments: ResultList, ValueList, unit, type");
|
||||
throw Base::TypeError(error);
|
||||
PyErr_SetString(PyExc_ValueError, error.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user