Skip to content

Commit

Permalink
Python: [skip ci] exception handling in PyInit to avoid to close appl…
Browse files Browse the repository at this point in the history
…ication
  • Loading branch information
wwmayer committed May 26, 2020
1 parent 6f3160d commit ff3cdfa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Base/UnitPyImp.cpp
Expand Up @@ -52,8 +52,14 @@ int UnitPy::PyInit(PyObject* args, PyObject* /*kwd*/)
int i7=0;
int i8=0;
if (PyArg_ParseTuple(args, "|iiiiiiii", &i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8)) {
*self = Unit(i1,i2,i3,i4,i5,i6,i7,i8);
return 0;
try {
*self = Unit(i1,i2,i3,i4,i5,i6,i7,i8);
return 0;
}
catch (const Base::OverflowError& e) {
PyErr_SetString(PyExc_OverflowError, e.what());
return -1;
}
}
PyErr_Clear(); // set by PyArg_ParseTuple()

Expand Down

0 comments on commit ff3cdfa

Please sign in to comment.