Python: [skip ci] exception handling in PyInit to avoid to close application

This commit is contained in:
wmayer
2020-05-26 22:55:07 +02:00
parent 9b59de44c2
commit 147b8404b4

View File

@@ -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()