Skip to content

Commit

Permalink
Fix long conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Sep 25, 2023
1 parent 9a5ae0d commit c2fe24d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/swig/nlopt-python.i
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ static double func_python(unsigned n, const double *x, double *grad, void *f)
val = PyFloat_AsDouble(result);
Py_DECREF(result);
}
else if (result && PyLong_Check(result)) {
val = PyLong_AsUnsignedLong(result);
Py_DECREF(result);
}
else {
Py_XDECREF(result);
throw std::invalid_argument("invalid result passed to nlopt");
Expand Down

0 comments on commit c2fe24d

Please sign in to comment.