From 4a449d1d0b6167d0b1f29402a621b345a69a8dcf Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 6 Jun 2020 13:04:01 +0200 Subject: [PATCH] App: [skip ci] throw an exception if the expression gives NaN --- src/App/Expression.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index b8c58d6d2c..b50a82fcd9 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -2301,7 +2301,12 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std _EXPR_THROW("Unknown function: " << f,expr); } - return Py::asObject(new QuantityPy(new Quantity(scaler * output, unit))); + Quantity q(scaler * output, unit); + if (!q.isValid()) { + throw Base::ValueError("Not a number"); + } + + return Py::asObject(new QuantityPy(new Quantity(q))); } Py::Object FunctionExpression::_getPyValue() const {