correctly handle again NotImplementedError in Python view providers

This commit is contained in:
wmayer
2019-02-22 13:26:33 +01:00
parent 77b22f4f30
commit 2631df09c0

View File

@@ -453,6 +453,12 @@ ViewProviderPythonFeatureImp::setEdit(int ModNum)
}
}
catch (Py::Exception&) {
// If an explicit NotImplementedError is raised then
// handle it differently to other RuntimeError
if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
PyErr_Clear();
return NotImplemented;
}
// If a runtime error occurred when calling setEdit
// then handle it like returning false
if (PyErr_ExceptionMatches(PyExc_RuntimeError)) {
@@ -503,6 +509,18 @@ ViewProviderPythonFeatureImp::unsetEdit(int ModNum)
}
}
catch (Py::Exception&) {
// If an explicit NotImplementedError is raised then
// handle it differently to other RuntimeError
if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
PyErr_Clear();
return NotImplemented;
}
// If a runtime error occurred when calling setEdit
// then handle it like returning false
if (PyErr_ExceptionMatches(PyExc_RuntimeError)) {
PyErr_Clear();
return Rejected;
}
Base::PyException e; // extract the Python error text
e.ReportException();
}