1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-28 23:03:03 +04:00

Proposed solution for issue #23633

This commit is contained in:
SoY Szala
2023-05-17 23:06:59 +02:00
parent d2143bcd44
commit 340e999c45
+18 -6
View File
@@ -54,12 +54,24 @@ PyObject* failmsgp(const char *fmt, ...)
void pyRaiseCVException(const cv::Exception &e)
{
PyObject_SetAttrString(opencv_error, "file", PyString_FromString(e.file.c_str()));
PyObject_SetAttrString(opencv_error, "func", PyString_FromString(e.func.c_str()));
PyObject_SetAttrString(opencv_error, "line", PyInt_FromLong(e.line));
PyObject_SetAttrString(opencv_error, "code", PyInt_FromLong(e.code));
PyObject_SetAttrString(opencv_error, "msg", PyString_FromString(e.msg.c_str()));
PyObject_SetAttrString(opencv_error, "err", PyString_FromString(e.err.c_str()));
PyObject* temp_obj = PyString_FromString(e.file.c_str());
PyObject_SetAttrString(opencv_error, "file", temp_obj);
Py_DECREF(temp_obj);
temp_obj = PyString_FromString(e.func.c_str());
PyObject_SetAttrString(opencv_error, "func", temp_obj);
Py_DECREF(temp_obj);
temp_obj = PyInt_FromLong(e.line);
PyObject_SetAttrString(opencv_error, "line", temp_obj);
Py_DECREF(temp_obj);
temp_obj = PyInt_FromLong(e.code);
PyObject_SetAttrString(opencv_error, "code", temp_obj);
Py_DECREF(temp_obj);
temp_obj = PyString_FromString(e.msg.c_str());
PyObject_SetAttrString(opencv_error, "msg", temp_obj);
Py_DECREF(temp_obj);
temp_obj = PyString_FromString(e.err.c_str());
PyObject_SetAttrString(opencv_error, "err", temp_obj);
Py_DECREF(temp_obj);
PyErr_SetString(opencv_error, e.what());
}